I have been on a database project for a while now. I wanted to be able to make changes to my database using the update command of a Datagridview control.However, I have been faced with a series of unsuccessful outcomes.I want to do this how do I go about it?
Public Sub InsertInformation()
Dim connex As MySqlConnection
Dim theNumber, tryNumber As Integer
Dim MyCommandText, coll As String
Dim NameOne, RankOne, StaffNosOne, DepartmentOne, BankOne, AccountNosOne, BranchOne, AdditionCommentOne, DeductionCommentOne As String
Dim GradeOne, StepOne As Integer
Dim DriverAllowanceOne, PensionOne, VehicleOne, NonAccidentOne, AdditionOne, CTCSOne, DeductionsOne As Double
MyCommandText = " insert into " & MyFileTableText & " values(" & NameOne & "," & GradeOne & "," & StepOne & "," & RankOne & "," & _
StaffNosOne & "," & DepartmentOne & "," & BankOne & "," & AccountNosOne & "," & BranchOne & ");"
Try
connex = New MySqlConnection
connex.ConnectionString = "server=127.0.0.1;" & "uid=root;" & "pwd = instructed;"
connex.Open()
myCommand.Connection = connex
myAdapter.UpdateCommand = myCommand
Dim cmdbuilder As New MySqlCommandBuilder(myAdapter)
Dim i As Integer
Try
i = myAdapter.Update(myDataSet, "myData")
MsgBox("Records Updated= " & i)
Catch ex As Exception
MsgBox(ex.Message)
End Try
Catch myerror As MySqlException 'Exception
MessageBox.Show("Error UpdatingDatabase: " & myerror.Message)
connex.Close()
End Try
connex.Close()
connex.Dispose()
End Sub
This post has been edited by origen2g: 25 May 2010 - 06:56 AM

New Topic/Question
Reply




MultiQuote








|