| | |
Database update error help
Please support our C# advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2008
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.
C# Syntax (Toggle Plain Text)
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"; } }
•
•
Join Date: Aug 2008
Posts: 1,162
Reputation:
Solved Threads: 138
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
•
•
Join Date: Aug 2008
Posts: 1,162
Reputation:
Solved Threads: 138
an insert is a new row, an update is making changes to an existing row
example
example
C# Syntax (Toggle Plain Text)
INSERT INTO Users (USER_ID, USERNAME, PASSWORD) values (1, 'myusername', 'mypassword')
C# Syntax (Toggle Plain Text)
UPDATE Users set PASSWORD = 'newpassword' WHERE USER_ID = 1
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
•
•
Join Date: Nov 2008
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
C# Syntax (Toggle Plain Text)
LoginTable("Username","Password") values (txtUsernameInput.Text,txtPasswordInput.Text);
because I just tried that and it didn't work
Thanks for the help.
•
•
Join Date: Aug 2008
Posts: 1,162
Reputation:
Solved Threads: 138
the syntax would be
C# Syntax (Toggle Plain Text)
string sql = "INSERT INTO LoginTable (Username, Password) vaues ( \""+ txtUsernameInput.Text + "\", \"" + txtPasswordInput.Text + "\")";
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
•
•
Join Date: Aug 2008
Posts: 1,162
Reputation:
Solved Threads: 138
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
•
•
Join Date: Aug 2008
Posts: 1,162
Reputation:
Solved Threads: 138
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
- 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)
Other Threads in the C# Forum
- Previous Thread: how i can fetch the from datagrid
- Next Thread: Console calculator Part 1 : The Scanner
Views: 498 | Replies: 9
| Thread Tools | Search this Thread |
Tag cloud for C#
.net access ado.net algorithm array barchart bitmap box broadcast button buttons c# chat check checkbox class client color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development drawing encryption enum event excel file files form format ftp function gdi+ http httpwebrequest image index input install java label list listbox login mandelbrot math mouseclick mysql networking object oracle path photoshop picturebox pixelinversion post prime programming radians regex remote remoting resource richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view webbrowser windows winforms wpf xml






