-
Jan 26th, 2012, 11:02 AM
#1
Thread Starter
Hyperactive Member
[Help] Updating MySQL w/ VB.net
Okay so I have MySQL records pulling from my database into my form, i can go through them and it reads PERFECT, But when i go to click my save button , nothing updates in the database, i used Msgbox to see what the update line was and it all looked right, here is my code/ some screenshots
Code:
Dim strConn As String = "server=192.168.0.109;User Id=******;password=******;database=taxcert"
Dim dataadapter As New MySqlDataAdapter("SELECT Control_Number, OrderNumber, Date, County, Address, City, State, ZipCode, Owner1Last, Owner2Full, ParcelNumber, ClientParcel, EffectiveDate, ClassCode, Client, Product, DateOrderReceived, Status, FollowUpDate, Date_Received, Date_Cancelled, Date_Completed, KeyedBy, Searched_By, OnHoldDate, ReportApprovedBy, DateApproved, Comments, HoldReason, TSINotes FROM Orders", strConn)
Dim taxDS As New DataSet("Tax")
Dim dt As New DataTable("Orders")
Dim taxBS As BindingSource
Dim commands As New MySqlCommandBuilder(dataadapter)
Code:
Private Sub TaxCert_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
dataadapter.Fill(taxDS, "Orders")
dataadapter.UpdateCommand = commands.GetUpdateCommand
taxBS = New BindingSource(taxDS, ("Orders"))
BindingNavigator1.BindingSource = taxBS
Call loadfields()
End Sub
This is the save button
Code:
Private Sub SaveToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripButton.Click
Me.taxDS.EndInit()
Me.dataadapter.Update(taxDS.Tables("Orders"))
'MsgBox(commands.GetUpdateCommand.CommandText)
End Sub
And these are my loadfields
Code:
Private Sub loadfields()
'Text Field Data Bindings
txtCtrlNmb.DataBindings.Add("Text", taxBS, "Control_Number")
txtOrderNmb.DataBindings.Add("Text", taxBS, "OrderNumber")
txtOrderDate.DataBindings.Add("Text", taxBS, "Date")
txtCounty.DataBindings.Add("Text", taxBS, "County")
txtAddress.DataBindings.Add("Text", taxBS, "Address")
txtCity.DataBindings.Add("Text", taxBS, "City")
txtState.DataBindings.Add("Text", taxBS, "State")
txtZip.DataBindings.Add("Text", taxBS, "Zipcode")
txtCust1.DataBindings.Add("Text", taxBS, "Owner1Last")
txtCust2.DataBindings.Add("Text", taxBS, "Owner2Full")
txtParcelNmb.DataBindings.Add("Text", taxBS, "ParcelNumber")
txtClientParcel.DataBindings.Add("Text", taxBS, "ClientParcel")
txtEffDate.DataBindings.Add("Text", taxBS, "EffectiveDate")
txtClassCode.DataBindings.Add("Text", taxBS, "ClassCode")
txtClient.DataBindings.Add("Text", taxBS, "Client")
'txtLoanProcessor.DataBindings.Add("Text", taxBS, "LoanProcess")
txtProduct.DataBindings.Add("Text", taxBS, "Product")
'txtPriority.DataBindings.Add("Text", taxBS, "Priority")
txtOrderRecDate.DataBindings.Add("Text", taxBS, "DateOrderReceived")
'txtTimeRecieved.DataBindings.Add("Text", taxBS, "TimeOrderReceived")
txtStatus.DataBindings.Add("Text", taxBS, "Status")
txtFollowUp.DataBindings.Add("Text", taxBS, "FollowUpDate")
txtDateRecieved.DataBindings.Add("Text", taxBS, "Date_Received")
'txtDateDue.DataBindings.Add("Text", taxBS, "DateDue")
txtDateCancelled.DataBindings.Add("text", taxBS, "Date_Cancelled")
txtDateComp.DataBindings.Add("text", taxBS, "Date_Completed")
txtKeyedBy.DataBindings.Add("Text", taxBS, "KeyedBy")
txtSearchedBy.DataBindings.Add("Text", taxBS, "Searched_By")
'txtUploadedBy.DataBindings.Add("Text", taxBS, "UploadedBy")
txtHoldDate.DataBindings.Add("text", taxBS, "OnHoldDate")
'txtOffHold.DataBindings.Add("text", taxBS, "OffHoldDate")
txtRptApprBy.DataBindings.Add("Text", taxBS, "ReportApprovedBy")
txtDateAppr.DataBindings.Add("text", taxBS, "DateApproved")
txtComments.DataBindings.Add("text", taxBS, "Comments")
txtHoldReason.DataBindings.Add("text", taxBS, "HoldReason")
txtClientNote.DataBindings.Add("text", taxBS, "TSINotes")
End Sub
and this is the form running showing records
-
Jan 26th, 2012, 11:37 AM
#2
Re: [Help] Updating MySQL w/ VB.net
-
Jan 26th, 2012, 01:03 PM
#3
Hyperactive Member
Re: [Help] Updating MySQL w/ VB.net
did you call savechanges or whatever before saving?
-
Jan 26th, 2012, 01:27 PM
#4
Thread Starter
Hyperactive Member
Re: [Help] Updating MySQL w/ VB.net
I somehow found a fix for this, for future reference for anyone with the same problem here is the new save button code that fixed the issue :
Code:
Private Sub SaveToolStripButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripButton.Click
Try
Me.Validate()
taxBS.EndEdit()
Me.dataadapter.Update(taxDS.Tables("Orders"))
Catch ex As Exception
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
|