Nowadays I am working on one of my assignments in vb.net. Assignment is about making a software that work like ATM.
I am facing problem in this query for the access database
error is syntax error but there is no error as far i know
I will appreciate if you can help
statement is
cmd = New OleDbCommand("INSERT INTO Transaction VALUES('" & WithDrawTxt.Text & "','" & AccountNo.ToString & "','" & dt.ToString & "')", cn)
i = cmd.ExecuteNonQuery
Table Transaction has fields Amount, Account_Number, Transaction_Date and last is Transaction#. All have field text except Transaction# which is auto number.
I have changed it to following statement too but its not working even then
cmd = New OleDbCommand("INSERT INTO Transaction(Amount,Account_Number,Transaction_date) VALUES('" & WithDrawTxt.Text & "','" & AccountNo.ToString & "','" & dt.ToString & "')", cn)
i = cmd.ExecuteNonQuery

Guest UserRank #1,422 · 1.2K reputationPosted Dec 17, 2008, 10:49 AM EST
INSERT INTO [Transaction]
"Transaction" is a reserved word, meaning that it can cause problems if you use it as the name of a table or field. By placing square brackets around it you're telling the database that it's the name of an object.
Ayesha Hafeez3 reputationPosted Dec 18, 2008, 5:55 AM EST
Thanx for your concern
but this answer is not solving my problem
Guest UserRank #1,422 · 1.2K reputationPosted Dec 18, 2008, 6:44 AM EST
Dim s as string = "INSERT INTO Transaction(Amount,Account_Number,Transaction_date) VALUES('" & WithDrawTxt.Text & "','" & AccountNo.ToString & "','" & dt.ToString & "')"