hi,

i'm having a problem with this set of codes.
i'm trying to insert data into datatable and update it into a database but everytime i click the save button

an OledbException will occur

VB Code:
  1. Private myConnect As OleDbConnection
  2.     Private myDataadapter As OleDbDataAdapter
  3.     Private myDataTable As DataTable
  4.     Private cmbInsert As OleDbCommand    
  5.  
  6.     Private Sub FormItemType_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  7.         Dim dbConnect As String = "Provider=Microsoft.JET.OLEDB.4.0;data source=D:\prodType.mdb"
  8.  
  9.         myConnect = New OleDbConnection(dbConnect)
  10.         Dim mySqlQuery As String = "Select *from ProductTypeInfo"
  11.         myDataTable = New DataTable
  12.         myDataadapter = New OleDbDataAdapter(mySqlQuery, dbConnect)
  13.         cmbInsert = New OleDbCommand
  14.         cmbInsert.CommandText = "Insert into ProductTypeInfo (ProductTypeID, ProductTypeName) values (@ProductTypeID, @ProductTypeName)"
  15.         cmbInsert.Connection = myConnect
  16.         cmbInsert.Parameters.Add(New OleDbParameter("@ProductTypeID", OleDbType.BSTR))
  17.         cmbInsert.Parameters.Add(New OleDbParameter("@ProductTypeName", OleDbType.BSTR))
  18.         myDataadapter.InsertCommand = cmbInsert
  19.  
  20.         myConnect.Open()
  21.         myDataadapter.Fill(myDataTable)
  22.         myConnect.Close()
  23.         DataGrid1.DataSource = myDataTable
  24.  
  25.     End Sub
  26.  
  27.     Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
  28.         myConnect.Open()
  29.         myDataadapter.Update(myDataTable)
  30.  
  31.         myConnect.Close()
  32.     End Sub