Database update error help
Please support our C# advertiser: DiscountASP.NET – 3 Months Free on C# Web Hosting
![]() |
•
•
Posts: 5
Reputation:
Solved Threads: 0
I'm trying to write a questionnaire that gathers info of the user and then updates a database in Access. I've managed to write the program and everything works up to the point where it updates the database, at which point it displays the error message below:
OleDbException was unhandled
Syntax error in INSERT INTO statement
I've checked it and I can't find any syntax errors in it. Could someone help me out please? I'm very new to programming, so please try to explain in as simple terms as possible. The section of code is below. Thanks for your help.
OleDbException was unhandled
Syntax error in INSERT INTO statement
I've checked it and I can't find any syntax errors in it. Could someone help me out please? I'm very new to programming, so please try to explain in as simple terms as possible. The section of code is below. Thanks for your help.
if (Found == "F")
{
if (txtPasswordInput.Text == txtConfirmPassword.Text)
{
DataRow drNewRow = m_dtLoginTable.NewRow(); //creates variable
drNewRow["Username"] = txtUsernameInput.Text;
drNewRow["Password"] = txtPasswordInput.Text;
m_dtLoginTable.Rows.Add(drNewRow);
m_dtDataAdapter.Update(m_dtLoginTable); database
m_rowPosition = m_dtLoginTable.Rows.Count - 1;
new record
}
else
{
txtError.Text = "Passwords do not match";
}
}•
•
Posts: 1,157
Reputation:
Solved Threads: 133
what is the code for your insert statement? also are you sure you are needing an insert statement here, or an update
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
•
•
Posts: 1,157
Reputation:
Solved Threads: 133
an insert is a new row, an update is making changes to an existing row
example
example
INSERT INTO Users (USER_ID, USERNAME, PASSWORD) values (1, 'myusername', 'mypassword')
UPDATE Users set PASSWORD = 'newpassword' WHERE USER_ID = 1
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
•
•
Posts: 5
Reputation:
Solved Threads: 0
Sorry to act like such as novice but could you help me with what I would actually write.
I'm trying to insert txt.UsernameInput.Text and txt.PasswordInput.Text into the new row in the Username and Password columns. The name of the table is LoginTable and the name of the Access file is Login. So would I write something like this
because I just tried that and it didn't work
Thanks for the help.
I'm trying to insert txt.UsernameInput.Text and txt.PasswordInput.Text into the new row in the Username and Password columns. The name of the table is LoginTable and the name of the Access file is Login. So would I write something like this
LoginTable("Username","Password") values (txtUsernameInput.Text,txtPasswordInput.Text);because I just tried that and it didn't work
Thanks for the help.
•
•
Posts: 1,157
Reputation:
Solved Threads: 133
the syntax would be
string sql = "INSERT INTO LoginTable (Username, Password) vaues ( \""+ txtUsernameInput.Text + "\", \"" + txtPasswordInput.Text + "\")";
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
•
•
Posts: 1,157
Reputation:
Solved Threads: 133
but how are inserting the record? calling dataadapter update?
what are the commands that are set for insert, select, and delete on it?
what are the commands that are set for insert, select, and delete on it?
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
•
•
Posts: 1,157
Reputation:
Solved Threads: 133
sure thing, will you post your solution or what you needed to do, so others can learn from this as well
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
![]() |
Similar Threads
Other Threads in the C# Forum
- SQL UPDATE Error (VB.NET)
- Updating an Access database with a secondary form (VB.NET)
- oleDbCommand - Update (ASP.NET)
- oleDbCommand - Update (ASP.NET)
- Generic Host Process Error for Win32 (Viruses, Spyware and other Nasties)
- delete a record and update the dataset (VB.NET)
- error handling in VB6 + + ODBC + MySQL...(Help!!!!) (Visual Basic 4 / 5 / 6)
- help connecting a form to a database.. error message (ASP.NET)
- XP SP2 installation error: "unable to read from or write to the database" (Windows NT / 2000 / XP / 2003)
Other Threads in the C# Forum
- Previous Thread: how i can fetch the from datagrid
- Next Thread: TCPClient And TCPServer
•
•
•
•
Views: 450 | Replies: 9 | Currently Viewing: 1 (0 members and 1 guests)






Linear Mode