| | |
Database update error help
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
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,160
Reputation:
Solved Threads: 137
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,160
Reputation:
Solved Threads: 137
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,160
Reputation:
Solved Threads: 137
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,160
Reputation:
Solved Threads: 137
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,160
Reputation:
Solved Threads: 137
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
| Thread Tools | Search this Thread |
.net access algorithm alignment app array barchart bitmap box broadcast c# c#gridviewcolumn cast check checkbox client combobox communication concurrency control conversion csharp custom database datagrid datagridview dataset datatable datetime degrees development draganddrop drawing elevated encryption enum excel file focus form format forms function gdi+ hospitalmanagementsystem image index input install java label list listbox localization login mandelbrot math messagebox mouseclick mysql operator path photoshop picturebox pixelinversion plotting pointer post programming radians read regex remote remoting richtextbox server sleep socket sql statistics stream string stringformatting sun table text textbox thread time timer update usercontrol validation visualstudio webbrowser whileloop windows winforms wpf xml






