|
Thanks a lot for your suggestion. I ll try.
|
|
|
|
|
I have applied sorting to the columns of a gridview and it works fine. There is a command field ShowEditButton to allow the user to update a record. In the code behind, the RowEditing and RowCancelingEdit also work as intended. The problem is the RowUpdating event. When the event fires the row in the database does get updated, but the gridview continues to show the previous value. The page actually has to unload and reload to show the new value. If anyone has any idea how to overcome this issue it sure would be appreciated.
Gridview:
<asp:GridView ID="grdSeries" runat="server" AutoGenerateColumns="False" DataKeyNames="SeriesChrCode, ProductLine, ProcurementType" AllowSorting="true">
<Columns>
<asp:CommandField ShowEditButton="True" CausesValidation="False"/>
<asp:BoundField HeaderText="SeriesChrCode" ReadOnly="True" Visible="False" DataField="SeriesChrCode"/>
<asp:BoundField HeaderText="ProductLine" ReadOnly="True" Visible="False" DataField="ProductLine"/>
<asp:BoundField HeaderText="ProcurementType" ReadOnly="True" Visible="False" DataField="ProcurementType"/>
<asp:TemplateField HeaderText="Character Code" ItemStyle-HorizontalAlign="Center" SortExpression="SeriesChrCode">
<ItemTemplate><asp:Label ID="lblSeriesChrCode" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "SeriesChrCode") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="edit_SeriesChrCode" MaxLength="15" Text='<%#Bind(Container.DataItem, "SeriesChrCode") %>' />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ProductLine" ItemStyle-HorizontalAlign="Center" SortExpression="ProductLine">
<ItemTemplate><asp:Label ID="lblProductLine" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "ProductLine") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList runat="server" ID="edit_ProductLine" selectedvalue='<%#Bind(Container.DataItem, "ProductLine") %>' DataTextField="ProductLine" DataValueField="ProductLine" datasource ='<%# GetProductLines %>' />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ProcurementType" ItemStyle-HorizontalAlign="Center" SortExpression ="ProcurementType">
<ItemTemplate><asp:Label ID="lblProcurementType" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "ProcurementType") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList runat="server" ID="edit_ProcurementType" selectedvalue='<%#Bind(Container.DataItem, "ProcurementType") %>' DataTextField="ProcurementType" DataValueField="ProcurementType" datasource ='<%# GetProcurementTypes %>' />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Series Code Description" ItemStyle-HorizontalAlign="Center" SortExpression ="SeriesCodeDescription">
<ItemTemplate><asp:Label ID="lblSeriesCodeDescription" runat="server" Text='<%#DataBinder.Eval(Container.DataItem, "SeriesCodeDescription") %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="edit_SeriesCodeDescription" MaxLength="50" Text='<%#Bind(Container.DataItem, "SeriesCodeDescription") %>' />
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
RowEditing and RowCancelEdit subs (both work):
Private Sub grdSeries_RowCancelingEdit(sender As Object, e As GridViewCancelEditEventArgs) Handles grdSeries.RowCancelingEdit
grdSeries.EditIndex = -1
Dim o As New clsData
Dim dt As DataTable = o.GetSeries
grdSeries.DataSource = dt
grdSeries.DataBind()
'*************
'works fine
If Not IsNothing(Session("LastSort")) Then
Dim dv As DataView = Session("LastSort")
grdSeries.DataSource = dv
grdSeries.DataBind()
End If
End Sub
Private Sub grdSeries_RowEditing(sender As Object, e As GridViewEditEventArgs) Handles grdSeries.RowEditing
grdSeries.EditIndex = CInt(e.NewEditIndex)
Dim o As New clsData
Dim dt As DataTable = o.GetSeries
grdSeries.DataSource = dt
grdSeries.DataBind()
'*************
'works fine
If Not IsNothing(Session("LastSort")) Then
Dim dv As DataView = Session("LastSort")
grdSeries.DataSource = dv
grdSeries.DataBind()
End If
End Sub
RowUpdating (not rendering in grid):
Private Sub grdSeries_RowUpdating(sender As Object, e As GridViewUpdateEventArgs) Handles grdSeries.RowUpdating
Dim o As New clsData
'get the id of the row being updated
'product line and procurementtype are updateable
'they are also the primary key
Dim strSeriesChrCode As String = grdSeries.DataKeys(e.RowIndex).Values("SeriesChrCode")
Dim strProductLine As String = grdSeries.DataKeys(e.RowIndex).Values("ProductLine")
Dim strProcurementType As String = grdSeries.DataKeys(e.RowIndex).Values("ProcurementType")
Dim cntrl_0 As TextBox
cntrl_0 = CType(grdSeries.Rows(e.RowIndex).FindControl("edit_SeriesChrCode"), TextBox)
Dim strCntrl_0 As String = cntrl_0.Text
Dim cntrl_1 As DropDownList
cntrl_1 = CType(grdSeries.Rows(e.RowIndex).FindControl("edit_ProductLine"), DropDownList)
Dim strCntrl_1 As String = cntrl_1.Text
Dim cntrl_2 As DropDownList
cntrl_2 = CType(grdSeries.Rows(e.RowIndex).FindControl("edit_ProcurementType"), DropDownList)
Dim strCntrl_2 As String = cntrl_2.Text
Dim cntrl_3 As TextBox
cntrl_3 = CType(grdSeries.Rows(e.RowIndex).FindControl("edit_SeriesCodeDescription"), TextBox)
Dim strCntrl_3 As String = cntrl_3.Text
Dim b As Boolean = o.UpdateSeries(strCntrl_0, strCntrl_1, strCntrl_2, strCntrl_3, strSeriesChrCode, strProductLine, strProcurementType)
grdSeries.EditIndex = -1
'*******************
'sort order is ok and data is updated on backend but does not show on the front end
Dim dt As DataTable = o.GetSeries
grdSeries.DataSource = dt
grdSeries.DataBind()
If Not IsNothing(Session("LastSort")) Then
Dim dv As DataView = Session("LastSort")
grdSeries.DataSource = dv
grdSeries.DataBind()
End If
End Sub
|
|
|
|
|
The gridview doesn't automatically know what the database does; it may be updating a lot more, based on sprocs and triggers. Easiest and most used solution is to reload the grid.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
The link to NArrange does not seem to work anymore. Does anyone know where I can now get it, or is it defunct (now that 11 yesrs have passed since last update?)
|
|
|
|
|
Did you try looking for it on Nuget?
|
|
|
|
|
How code to Print a Bit map image to pos printer via comport in VB6
|
|
|
|
|
|
Simples, you don't. VB6 is no longer supported, and hasn't been for years. There's free alternatives available that can easily be integrated into your VB6-application. It'll be hard to find documentation on integrating since there's no one doing that anymore; but even with limited info, you should be able to launch an executable and retrieve its output for processing.
Now if you excuse me, I'm going to wash my hands.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hello Fellow Members,
Please I work in a company where land/site plans are used. These plans have coordinates on them. I want these coordinates to be entered which Google will take you to the exact plot.
In fact, any sample code or links will be welcomed.
Thanks
|
|
|
|
|
What have you tried?
Where are you stuck?
What help do you need?
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
|
There's free geolocation databases, but not even Google pretends to be "exact".
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
|
|
|
|
|
Hi all. I've seen how to do a file system watch on a local folder. Is it possible to watch a remote folder on an ftp site?
Code for local folder:
gfswWatchFolder = New System.IO.FileSystemWatcher()
gfswWatchFolder.Path = "C:\My Documents\Temp2"
gfswWatchFolder.NotifyFilter = IO.NotifyFilters.DirectoryName
gfswWatchFolder.NotifyFilter = gfswWatchFolder.NotifyFilter Or IO.NotifyFilters.FileName
gfswWatchFolder.NotifyFilter = gfswWatchFolder.NotifyFilter Or IO.NotifyFilters.Attributes
AddHandler gfswWatchFolder.Changed, AddressOf LogChange
AddHandler gfswWatchFolder.Created, AddressOf LogChange
AddHandler gfswWatchFolder.Deleted, AddressOf LogChange
AddHandler gfswWatchFolder.Renamed, AddressOf LogChange
gfswWatchFolder.EnableRaisingEvents = True
and
<pre> Private Sub LogChange(ByVal source As Object, ByVal e As System.IO.FileSystemEventArgs)
If e.ChangeType = IO.WatcherChangeTypes.Changed Then
TextBoxMultiLine1.Text = "File " & e.FullPath & " has been modified." & vbCrLf
End If
If e.ChangeType = IO.WatcherChangeTypes.Created Then
TextBoxMultiLine1.Text = "File " & e.FullPath & " has been created." & vbCrLf
End If
If e.ChangeType = IO.WatcherChangeTypes.Deleted Then
TextBoxMultiLine1.Text = "File " & e.FullPath & " has been deleted." & vbCrLf
End If
If e.ChangeType = IO.WatcherChangeTypes.Renamed Then
TextBoxMultiLine1.Text = "File " & e.FullPath & " has been renamed." & vbCrLf
End If
End Sub
I know how to open a remote folder using
<pre>Dim request As FtpWebRequest = DirectCast(WebRequest.Create(mstrFTPUri & strRemoteApplicationFolder), FtpWebRequest)
etc. etc. but how do I combine the two? Thanks in advance.
|
|
|
|
|
FileSystemWatcher only works for folders on your local PC, and folders on other computers on your LAN which you can access using a UNC path. It does not support monitoring an FTP folder.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
To delete the Category I use Code :
Private Sub DeleteCategories()
Dim objNS As NameSpace
Dim objCat As Category
Set objNS = Application.GetNamespace("MAPI")
If objNS.Categories.Count > 0 Then
For Each objCat In objNS.Categories
objNS.Categories.Remove (objCat.CategoryID)
Next
End If
Set objCat = Nothing
Set objNS = Nothing
End Sub
=========
Then to Restore Categories I use:
Sub RestoreCategories()
AddCategory "1", 4, 0
AddCategory "2", 18, 0
AddCategory "3", 22, 0
AddCategory "4", 14, 0
AddCategory "5", 5, 0
AddCategory "6", 7, 0
AddCategory "7", 6, 0
AddCategory "8", 9, 0
AddCategory "9", 8, 0
AddCategory "10", 10, 0
AddCategory "11", 2, 0
End Sub
Where the issue is it works in personal Account but not in Shared mailboxes ? Any Ideas.
|
|
|
|
|
By using objNs from GetNameSpace you are using the default account. You have to get hold of the Store for (each) shared mailbox Account and manipulate that instead.
Sorry I don't have a specific working example but the following link might help point you in the right direction. If nothing else you now know what the problem is to help your research
Working with VBA and non-default Outlook Folders[^]
|
|
|
|
|
I am calling Form_BeforeUpdate directly from a Close (Form) button's onClick Event, to handle various circumstances when the form is only partially filled in but the User wants to bail out. Under certain (perfectly feasible) circumstances, Form_BeforeUpdate is correctly setting Cancel to True within itself, but it is not being passed back to the calling Sub! Subroutine parameters are ByRef by default, but setting Cancel explicitly to ByRef in the definition of Form_BeforeUpdate does not change the misbehavior. Here are the two Subs:
Private Sub cmdClose_Click()
Dim Cancel As Integer
Form_BeforeUpdate (Cancel)
If Cancel Then
If MsgBox("This record contains errors. Do you wish to correct them before closing the form?", vbYesNo, "Errors") = vbYes Then
Exit Sub
Else
If Me.NewRecord Then
MsgBox "The current record will be discarded.", vbInformation
Else
MsgBox "Any changes made to the current record will be discarded.", vbInformation
End If
Me.Undo
End If
End If
blMayClose = True
DoCmd.Close acForm, Me.Name
End Sub
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim rst As New ADODB.Recordset
If Me.NewRecord Then Contact_Pt = lbxContacts.Value
Set rst = New ADODB.Recordset
rst.Open "SELECT ID FROM Assets WHERE package_Pt = " & ID, CurrentProject.Connection, adOpenStatic, adLockReadOnly
If Not (rst.EOF And rst.BOF) Then
If IsNull(Start_Date.Value) Or IsNull(End_Date.Value) Then 'this is where Cancel gets set to True
MsgBox "You must enter start and end dates for the package before saving it.", vbExclamation, "Dates Missing"
Cancel = True
ElseIf End_Date.Value <= Start_Date.Value Then
MsgBox "The end date must be after the start date.", vbExclamation, "Invalid dates"
Cancel = True
End If
End If
rst.Close
Set rst = Nothing
End Sub
|
|
|
|
|
The way you are calling the sub is strange
Form_BeforeUpdate (Cancel) That should be either
Call Form_BeforeUpdate(Cancel) or
Form_BeforeUpdate Cancel I can't remember what surrounding a variable in parentheses does, other than make that code not work obviously .
I'll have a dig around, but in the meantime either insert "Call" or drop the ()
|
|
|
|
|
Found it!
Using the parentheses is forcing VBA to evaluate the bracketed expression (in this case, your variable Cancel ) and then pass it as ByVal into the subroutine. Ergo the value remains unchanged in the calling sub.
See Matthieu Guindon's solution here [^] for a fuller explanation
|
|
|
|
|
Thanks! I had given up and used a workaround (which actually turned out to have other advantages, so it wasn't all bad). VBA's requirement that you not surround sub/function arguments with parens (unless you make an explicit Call) is always catching me out, since every other language I use require the parens. Fortunately, it mostly affects implicit calls with multiple arguments, where putting in the parens provokes an immediate syntax error in the editor. This case is a particular pain since the bad syntax is not flagged but nevertheless changes the meaning of the call.
|
|
|
|
|
VBScript and VBA require parenthesis around the parameters of functions that return a value.
For functions that don't returns a value, no parenthesis go around the parameter list.
It's the stupidest thing I've ever seen.
On, and you never need to use "Call" to call another function at all.
|
|
|
|
|
1: It's the stupidest thing I've ever seen. I couldn't agree with you more!
2: and you never need to use "Call" to call another function at all. Except when you put parentheses around your parameter list. In which case quote 1 applies
|
|
|
|
|
In the mountain of VB6, VBA, and VBScript code I've written, I've never used 'Call'. It just seemed so COBOL to me, YUK!
|
|
|
|
|
|
I want to Use the following Com Funktion ( From idl File)
[id(2)] HRESULT Request ( [in] long id, [in] BSTR version, [in,out] BSTR sender, [in] BSTR login, [in] BSTR selection, [in, out] BSTR* data , [out, retval] long* retval );
from my Visual Basic Scriot ( Visual Studion 2015) wenn i call my funktion from ma scrip like tis
Private Sub Request_1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Request_1.Click
Dim r As Integer
Dim data As String
Dim ID As String
Dim sender As String
sender = "DatO"
If ID_KS_1.Text <> "" Then
ID = "ID_KS=" & ID_KS_1.Text & ","
sender = "KS_Trifact"
End If
ErrorText.Text = ""
If obj Is Nothing Then obj = CreateObject("NmsTaskDbSv.64Bit_NmsDbData")
'UPGRADE_WARNING: Couldn't resolve default property of object obj.Request. Click for more: 'ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?keyword="6A50421D-15FE-4896-8A1B-2EC21E9037B2"'
'r = obj.Request(15101, "1.0", sender, "customerservice/customer", ID & "ACCOUNT=" & Par_1_1.Text, "test")
r = obj.Request(15101, "1.0", sender, "customerservice/customer", ID & "ACCOUNT=" & Par_1_1.Text, (data))
If (r = 0) Then
Result_1.Text = data
Else
ShowLastError()
End If
End Sub
it seams to work but rhe response dues not arrive in the data variablele wenn i make the call j = CreateObject without () lik this
'r = obj.Request(15101, "1.0", sender, "customerservice/customer", ID & "ACCOUNT=" & Par_1_1.Text, data)
i get a type mismatch error ho i have to call Request to get the Data String as answer
Thanks
|
|
|
|
|