473,406 Members | 2,633 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

An unhandled exception of type 'System.Data.OleDb.OleDbException' occurred in sy

this is the error i get

System.Data.OleDb.OleDbException: Syntax error in INSERT INTO statement.
at System.Data.Common.DbDataAdapter.Update(DataRow[] dataRows,
DataTableMapping tableMapping)
at System.Data.Common.DbDataAdapter.Update(DataSet dataSet, String
srcTable)
at System.Data.Common.DbDataAdapter.Update(DataSet dataSet)
at TryThis.Form1.save() in C:\Documents and Settings\Nick\My Documents\
Vb.net_Practice\TryThis\TryThis\Form1.vb:line 310
heres my source code
Me.OleDbConnection1.ConnectionString = "Jet OLEDB:Global Partial Bulk
Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database L" & _
"ocking Mode=1;Data Source=""C:\Documents and Settings\Nick\My
Documents\TryThis.m" & _
"db"";Mode=Share Deny None;Jet OLEDB:Engine
Type=5;Provider=""Microsoft.Jet.OLEDB.4" & _
".0"";Jet OLEDB:System database=;Jet OLEDB:SFP=False;persist
security info=False;E" & _
"xtended Properties=;Jet OLEDB:Compact Without Replica
Repair=False;Jet OLEDB:Enc" & _
"rypt Database=False;Jet OLEDB:Create System Database=False;Jet
OLEDB:Don't Copy " & _
"Locale on Compact=False;User ID=Admin;Jet OLEDB:Global Bulk
Transactions=1"
'
'OleDbDataAdapter1
'
Me.OleDbDataAdapter1.DeleteCommand = Me.OleDbDeleteCommand1
Me.OleDbDataAdapter1.InsertCommand = Me.OleDbInsertCommand1
Me.OleDbDataAdapter1.SelectCommand = Me.OleDbSelectCommand1
Me.OleDbDataAdapter1.TableMappings.AddRange(New
System.Data.Common.DataTableMapping() {New
System.Data.Common.DataTableMapping("Table", "tblCredit", New
System.Data.Common.DataColumnMapping() {New
System.Data.Common.DataColumnMapping("Amount", "Amount"), New
System.Data.Common.DataColumnMapping("Date", "Date"), New
System.Data.Common.DataColumnMapping("ID", "ID"), New
System.Data.Common.DataColumnMapping("Memo", "Memo"), New
System.Data.Common.DataColumnMapping("Name", "Name"), New
System.Data.Common.DataColumnMapping("Transaction" , "Transaction")})})
Me.OleDbDataAdapter1.UpdateCommand = Me.OleDbUpdateCommand1
'
'OleDbSelectCommand1
'
Me.OleDbSelectCommand1.CommandText = "SELECT Amount, [Date], ID,
[Memo], Name, Transaction FROM tblCredit"
Me.OleDbSelectCommand1.Connection = Me.OleDbConnection1
'
'OleDbInsertCommand1
'
Me.OleDbInsertCommand1.CommandText = "INSERT INTO tblCredit(Amount,
[Date], [Memo], Name, Transaction) VALUES (?, ?, ?," & _
" ?, ?)"
Me.OleDbInsertCommand1.Connection = Me.OleDbConnection1
Me.OleDbInsertCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Amount",
System.Data.OleDb.OleDbType.VarWChar, 50, "Amount"))
Me.OleDbInsertCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Date",
System.Data.OleDb.OleDbType.VarWChar, 50, "Date"))
Me.OleDbInsertCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Memo",
System.Data.OleDb.OleDbType.VarWChar, 50, "Memo"))
Me.OleDbInsertCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Name",
System.Data.OleDb.OleDbType.VarWChar, 50, "Name"))
Me.OleDbInsertCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Transaction",
System.Data.OleDb.OleDbType.VarWChar, 50, "Transaction"))
'
'OleDbUpdateCommand1
'
Me.OleDbUpdateCommand1.CommandText = "UPDATE tblCredit SET Amount =
?, [Date] = ?, [Memo] = ?, Name = ?, Transaction = " & _
"? WHERE (ID = ?) AND (Amount = ? OR ? IS NULL AND Amount IS NULL)
AND ([Date] = " & _
"? OR ? IS NULL AND [Date] IS NULL) AND ([Memo] = ? OR ? IS NULL
AND [Memo] IS NU" & _
"LL) AND (Name = ? OR ? IS NULL AND Name IS NULL) AND (Transaction
= ? OR ? IS NU" & _
"LL AND Transaction IS NULL)"
Me.OleDbUpdateCommand1.Connection = Me.OleDbConnection1
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Amount",
System.Data.OleDb.OleDbType.VarWChar, 50, "Amount"))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Date",
System.Data.OleDb.OleDbType.VarWChar, 50, "Date"))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Memo",
System.Data.OleDb.OleDbType.VarWChar, 50, "Memo"))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Name",
System.Data.OleDb.OleDbType.VarWChar, 50, "Name"))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Transaction",
System.Data.OleDb.OleDbType.VarWChar, 50, "Transaction"))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_ID",
System.Data.OleDb.OleDbType.Integer, 0,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte)
, "ID", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_Amount" ,
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte)
, "Amount", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_Amount1 ",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte)
, "Amount", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_Date",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte)
, "Date", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_Date1",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte)
, "Date", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_Memo",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte)
, "Memo", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_Memo1",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte)
, "Memo", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_Name",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte)
, "Name", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_Name1",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte)
, "Name", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_Transac tion",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte)
, "Transaction", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbUpdateCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_Transac tion1",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte)
, "Transaction", System.Data.DataRowVersion.Original, Nothing))
'
'OleDbDeleteCommand1
'
Me.OleDbDeleteCommand1.CommandText = "DELETE FROM tblCredit WHERE
(ID = ?) AND (Amount = ? OR ? IS NULL AND Amount IS N" & _
"ULL) AND ([Date] = ? OR ? IS NULL AND [Date] IS NULL) AND ([Memo]
= ? OR ? IS NU" & _
"LL AND [Memo] IS NULL) AND (Name = ? OR ? IS NULL AND Name IS NULL)
AND (Transac" & _
"tion = ? OR ? IS NULL AND Transaction IS NULL)"
Me.OleDbDeleteCommand1.Connection = Me.OleDbConnection1
Me.OleDbDeleteCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_ID",
System.Data.OleDb.OleDbType.Integer, 0,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte)
, "ID", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbDeleteCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_Amount" ,
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte)
, "Amount", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbDeleteCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_Amount1 ",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte)
, "Amount", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbDeleteCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_Date",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte)
, "Date", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbDeleteCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_Date1",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte)
, "Date", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbDeleteCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_Memo",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte)
, "Memo", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbDeleteCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_Memo1",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte)
, "Memo", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbDeleteCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_Name",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte)
, "Name", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbDeleteCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_Name1",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte)
, "Name", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbDeleteCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_Transac tion",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte)
, "Transaction", System.Data.DataRowVersion.Original, Nothing))
Me.OleDbDeleteCommand1.Parameters.Add(New
System.Data.OleDb.OleDbParameter("Original_Transac tion1",
System.Data.OleDb.OleDbType.VarWChar, 50,
System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte)
, "Transaction", System.Data.DataRowVersion.Original, Nothing))
'
'DataSet11
'
Me.DataSet11.DataSetName = "DataSet1"
Me.DataSet11.Locale = New System.Globalization.CultureInfo("en-US")
'

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Timer1.Enabled = False
Bind()
OleDbDataAdapter1.Fill(DataSet11)
End Sub
Private Sub Bind()
Dim bind As Binding
bind = New Binding("text", DataSet11, "tblCredit.Date")
TextBox1.DataBindings.Add(bind)
bind = New Binding("text", DataSet11, "tblCredit.Transaction")
TextBox2.DataBindings.Add(bind)
bind = New Binding("text", DataSet11, "tblCredit.Name")
TextBox3.DataBindings.Add(bind)
bind = New Binding("text", DataSet11, "tblCredit.Amount")
TextBox4.DataBindings.Add(bind)
bind = New Binding("text", DataSet11, "tblCredit.ID")
TextBox6.DataBindings.Add(bind)
bind = New Binding("text", DataSet11, "tblCredit.Memo")
TextBox7.DataBindings.Add(bind)

End Sub
Private Sub save()

Dim InsertRow, ModRow, delRow As DataSet

Me.BindingContext(DataSet11, "tblCredit").EndCurrentEdit()
InsertRow = DataSet11.GetChanges(DataRowState.Added)
ModRow = DataSet11.GetChanges(DataRowState.Modified)
delRow = DataSet11.GetChanges(DataRowState.Deleted)
Try
If Not InsertRow Is Nothing Then
OleDbDataAdapter1.Update(InsertRow)
End If
Catch ex As Exception
TextBox5.Text = Convert.ToString(ex)
End Try

If Not ModRow Is Nothing Then
OleDbDataAdapter1.Update(ModRow)

End If
If Not delRow Is Nothing Then
OleDbDataAdapter1.Update(delRow)
End If
DataSet11.AcceptChanges()
'An unhandled exception of type 'System.Data.OleDb.OleDbException'
occurred in system.data.dll

End Sub

Private Sub btnBack_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnBack.Click
Me.BindingContext(DataSet11, "tblCredit").Position -= 1

End Sub

Private Sub btnNext_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNext.Click
Me.BindingContext(DataSet11, "tblCredit").Position += 1
End Sub

Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSave.Click
save()
End Sub

Private Sub btnNew_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnNew.Click
Me.BindingContext(DataSet11, "tblCredit").AddNew()
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
TextBox5.Text = Me.BindingContext(DataSet11, "tblCredit").Position
End Sub
End Class

--
Message posted via http://www.dotnetmonster.com
Nov 19 '05 #1
0 5603

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Professor Frink | last post by:
First off, I apologize if this gets long. I'm simply trying to give you all enough information to help me out. I'm writing (almost finished, actually), my first VB.Net application. It's a forms...
4
by: Craig831 | last post by:
First off, I apologize if this gets long. I'm simply trying to give you all enough information to help me out. I'm writing (almost finished, actually), my first VB.Net application. It's a forms...
0
by: Chumley Walrus | last post by:
I'm trying to do an easy display of a few fields from a MSAccess database on an aspx page in vb.net, but I get an error at the "cy.DataSource = Cmd.ExecuteReader()" line :...
0
by: Chumley Walrus | last post by:
I'm trying to do an easy display of a few fields from a MSAccess database on an aspx page in vb.net, but I get an error at the "cy.DataSource = Cmd.ExecuteReader()" line :...
3
by: Stephen Flynn | last post by:
If I run my program on another machine I get the following error An unhandled exception of type 'System.ExecutionEngineException' occurred in System.Data.dll This happens with I try to open an...
3
by: bardiyam | last post by:
hi Im trying to create connection in c# with Access database and got exception at command.ExecuteNonQuery()-- Unhandled Exception of type 'System.Data.OleDb.OleDbException' occured in...
0
by: rmcpherson | last post by:
Can someone please help with this problem? I'm trying to go to the last record, make a new record, and save it the database. It just gives me "OleDbException was unhandled" error at da.Update(ds,...
3
by: hathan | last post by:
Can anyone explain why this code doesnt delete from the database. Some times it works and some times it errors i am confused. Private Sub DeleteBtn_Click(ByVal sender As System.Object, ByVal e As...
2
by: lily86 | last post by:
i'm very new so i hope all of u can help me. when i debug my webforms this error occur "An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll Additional...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.