'System.Data.OleDb.OleDbException'

netlurch

New member
Joined
May 21, 2003
Messages
2
Location
Central Pennsylvania
I cant figure this out. I keep getting this error with my VB.Net app

An unhandled exception of type System.Data.OleDb.OleDbException occurred in system.data.dll

It stops on this line :

MynCommand.ExecuteNonQuery()

Heres the sub code (Ive hardocded the insert statement thinking that was the problem, so the parameters arent being used in the code below) :

Sub StoreWinningData(ByVal bubbleid As Integer, ByVal name As String, ByVal totalvotes As Integer)
Dim MynSQL As String
MynSQL = "INSERT INTO temp_reportdata (bubbleid, name, votes) VALUES (1,Jon,2)"
MsgBox(MynSQL)
Dim MynConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\scantron.mdb")
Dim MynCommand As New OleDbCommand(MynSQL, MynConnection)
MynCommand.Connection.Open()
MynCommand.ExecuteNonQuery()
MynConnection.Close()
MynCommand.Dispose()
End Sub

I appreciate any tips / help anyone can lend.
 
try catch

Put try and catch statements maybe you could find something
more about error message!

Code:
Sub StoreWinningData(ByVal bubbleid As Integer, ByVal name As String, ByVal totalvotes As Integer)
Dim MynSQL As String
MynSQL = "INSERT INTO temp_reportdata (bubbleid, name, votes) VALUES (1,Jon,2)"
MsgBox(MynSQL)
Dim MynConnection As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=e:\scantron.mdb")
Dim MynCommand As New OleDbCommand(MynSQL, MynConnection)
MynCommand.Connection.Open()
try
MynCommand.ExecuteNonQuery()

catch errobj as new Exception()
Messagebox.Show(errobj.Message)
endtry
MynConnection.Close()
MynCommand.Dispose()
End Sub
 
You rock ! (and so does that code)

Ahhhhh.... Im an idiot !!

...had a field missing in the database table. Cant believe that. The Insert statement was dying because it couldnt find the field.

works like a charm now.

Thanks again for that code which will be getting used a lot now !
 
Back
Top