Database update - please help

djiceman

Member
Joined
Oct 20, 2006
Messages
10
Location
South Africa
Programming Experience
3-5
Ive spent many days just googling source code ad help. But nothing seems to work. Im using .net 1.1 with vb.net 2003

This is the error I get when updating the database:

Additional information: No error information available: E_FAIL(0x80004005).

Actualy the source code is taken from another post on this forum, but Ive tried similar code and I always get the above error on this line:
MyUpdateCommand = myCommand.GetUpdateCommand
Source code:
Dim myOleDbDataAdapter As OleDb.OleDbDataAdapter
Dim myDataSet As DataSet = New DataSet
Dim myDataTable As DataTable = New DataTable
Dim myOleDbConnection As OleDb.OleDbConnection
Dim myCommand As OleDb.OleDbCommandBuilder
Dim artKeySave As Integer
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
myOleDbConnection = New OleDb.OleDbConnection("Provider=MySQLProv;Data Source=dbname;User Id=dbuser;Password=dbpass;")
Try
myOleDbDataAdapter = _
New OleDb.OleDbDataAdapter("select * from client", _
myOleDbConnection)
myOleDbDataAdapter.Fill(myDataTable)
ListBox1.DataSource = myDataTable
ListBox1.DisplayMember = "name"
Catch
'Console.WriteLine("Error Opening {0}", _
'myOleDbConnection.DataSource)
End Try
myCommand = New OleDb.OleDbCommandBuilder(myOleDbDataAdapter)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim rowArticle As DataRow = myDataTable.NewRow()
rowArticle("name") = TextBox1.Text
'rowArticle("name") = "Don"
myDataTable.Rows.Add(rowArticle)
Dim MyUpdateCommand As OleDb.OleDbCommand
MyUpdateCommand = myCommand.GetUpdateCommand
myOleDbDataAdapter.UpdateCommand = MyUpdateCommand
'THE PROBLEM SEEMS TO BE HERE
Try
myOleDbDataAdapter.Update(myDataTable)
Catch Ex As Exception
MessageBox.Show(Ex.Message)
End Try

End Sub

Can someone please show me how to update the database in any other method. Or can someone show me how to use command to update instead.

Thanks
 
Last edited:
Top Bottom