Mothra
Well-known member
I am having megga trouble with this bit of code and I just can not see why its not working. Can someone PLEASE take a look and open my eyes so I may see the light?!?
The code is as follows:
The error Im getting comes when I call the DataAdapter.Update method and is an...
"Invalid argument or procedure call"
I just cant see whats not right...
Thanks!
The code is as follows:
Code:
Add work order to database
Public Function AddToDB(ByVal wo As clsWorkOrder)
Declarations
Dim cn As OleDbConnection
Dim cnStr As String
Dim strSQL As String
Dim dsNewWO As DataSet
Dim daNewWO As OleDbDataAdapter
Dim drNew As DataRow
Set the connection string value
cnStr = _
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=M:\MTRS\DB\MADB.mdb"
strSQL = "SELECT * FROM MADB"
Try Add the work order information to the database
Connect to the database
cn = New OleDbConnection(cnStr)
cn.Open()
Create & Fill the data adapter
daNewWO = New OleDbDataAdapter(strSQL, cn)
daNewWO.SelectCommand = New OleDbCommand(strSQL, cn)
Dim autoGen As OleDbCommandBuilder = New OleDbCommandBuilder(daNewWO)
dsNewWO = New DataSet("MADB")
daNewWO.FillSchema(dsNewWO, SchemaType.Source, "MADB")
daNewWO.Fill(dsNewWO)
drNew = dsNewWO.Tables("MADB").NewRow
With drNew
.BeginEdit()
Code to update my DataRow is here...
Its far to long to post and it works anyway...
.EndEdit()
End With
Add the new row to the table
dsNewWO.Tables("MADB").Rows.Add(drNew)
Update the data in the database
daNewWO.Update(dsNewWO)
Inform the user that the work order was added
MsgBox("Work Order # " & mJobNumber & Chr(13) & "has been added to the database", _
MsgBoxStyle.Information, "New Work Order...")
Catch ex As Exception
MsgBox(Err.Description & " " & Err.Number & Chr(13) & ex.Message)
Exit Function
Finally
Close the database connection and data elements
cn.Close()
cn = Nothing
daNewWO = Nothing
dsNewWO = Nothing
drNew = Nothing
End Try
End Function
The error Im getting comes when I call the DataAdapter.Update method and is an...
"Invalid argument or procedure call"
I just cant see whats not right...
Thanks!