|
-
Mar 9th, 2004, 02:41 PM
#1
Thread Starter
New Member
Dataset not updating
If I assign the value in the textbox to the variable vUser, the check of HasChanges fails; even though the msgbox shows the correct value for vUser.
If I assign the value of vUser in code to something ex. "Hello" Then the HasChanges passes and the rest of the code runs.
Any help is appreciated.
Dim vUser As String
Dim vDist As String
Dim vCarrier As String
Dim Ret As Integer
Try
vUser = Me.TextBox2.Text
vDist = TextBox3.Text
vCarrier = TextBox4.Text
MsgBox(vUser)
TextBox2.Text = vUser
mydataset.Tables("tblcarrier").Rows(0).Item("Name") = vUser
Dim Dt As DataTable = mydataset.Tables("tblcarrier")
Dim NewDt As DataTable = Dt.GetChanges(DataRowState.Modified)
If Not mydataset.HasChanges(DataRowState.Modified) Then Exit Sub
' Create temporary DataSet variable.
Dim xDataSet As DataSet
' GetChanges for modified rows only.
xDataSet = mydataset.GetChanges(DataRowState.Modified)
' Check the DataSet for errors.
If xDataSet.HasErrors Then
' Insert code to resolve errors.
End If
MsgBox("made it3")
' After fixing errors, update the data source with the DataAdapter
' used to create the DataSet.
adpCarriers.Update(xDataSet, "tblcarrier")
MsgBox("Made it4")
Catch ex As Exception
System.Diagnostics.Debug.WriteLine(ex.Message & "l " & ex.StackTrace)
'Finally
conn.Close()
End Try
End Sub
-
Mar 11th, 2004, 09:34 AM
#2
Thread Starter
New Member
-
Mar 12th, 2004, 06:43 AM
#3
Lively Member
Is this all of your code as it seems to have stuff missing like filling the dataset with the information from a file, database, or by just plain code.
Last edited by Tek; Mar 12th, 2004 at 06:46 AM.
===============
Tek
===============
-
Mar 12th, 2004, 10:49 AM
#4
Thread Starter
New Member
Yes, the dataset is populated
The dataset is populated and shows on the form.
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
conn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" & _
"F:\Vendor_Compliance.mdb"
adpCarriers.TableMappings.Add("Table", "tblcarrier")
adpWHSE.TableMappings.Add("Table", "tblWarehouse")
adpVENDOR.TableMappings.Add("Table", "tblVendor")
adpCarriers.SelectCommand = New System.Data.OleDb.OleDbCommand(mySelectQuery, conn)
adpWHSE.SelectCommand = New System.Data.OleDb.OleDbCommand(mySelectQuery2, conn)
adpVENDOR.SelectCommand = New System.Data.OleDb.OleDbCommand(mySelectQuery3, conn)
Try
conn.Open()
adpCarriers.Fill(mydataset)
adpWHSE.Fill(WHSEdataset)
adpVENDOR.Fill(VENDORdataset)
Mytable = mydataset.Tables(0)
TextBox1.DataBindings.Add(New Binding("Text", mydataset, "tblcarrier.carrierid"))
TextBox2.DataBindings.Add(New Binding("Text", mydataset, "tblcarrier.name"))
cbWarehouse.DataSource = WHSEdataset.Tables("tblWarehouse")
cbWarehouse.DisplayMember = "Name"
cbVendor.DataSource = VENDORdataset.Tables("tblVendor")
cbVendor.DisplayMember = "Name"
Catch ex As Exception
System.Diagnostics.Debug.WriteLine(ex.Message & "l " & ex.StackTrace)
conn.Close()
End Try
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|