| | |
Syntax error in SQL update string
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2009
Posts: 8
Reputation:
Solved Threads: 0
Hi all
Sorry- The title was wrong, My problem is when I type a the ID number in the text box for updating the record, it gives me an error "Data type mismatch in criteria expression."
Could anyone help me please in solving this problem?
This is my update code.
Thanks in Advance
Sorry- The title was wrong, My problem is when I type a the ID number in the text box for updating the record, it gives me an error "Data type mismatch in criteria expression."
Could anyone help me please in solving this problem?
This is my update code.
VB.NET Syntax (Toggle Plain Text)
cn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\HRIS.mdb;") cn.Open() Dim strupdate As String strupdate = "update Employees set [Name] ='" & txtName.Text & "',Mobile ='" & txtMob.Text & "',Home_Phn ='" & txtHomePhn.Text & "',Date_Birth ='" & txtAge.Text & "',CPR='" & txtCPR.Text & _ "', Address='" & txtAdd.Text & "',email='" & txtEmail.Text & "',Date_hiring='" & txtWorkDate.Text & "',Department='" & txtDep.Text & "',basic_salary='" & txtSal.Text & "'where ID='" & txtSearch.Text & "'" cmd = New OleDbCommand(strupdate, cn) cmd.ExecuteNonQuery() cn.Close()
Thanks in Advance
Last edited by nanoh2001; Jun 9th, 2009 at 3:18 pm. Reason: wrong title and case
Hi nanoh2001,
I believe your problem is the fact that you are trying to update all fields in your table with string values. If the fields in the table are not all strings then you will get the error you are geting.
I notice that there is a date field you are updating. If this field is a date field and the value you are supplying is not in a valid date format, then the error you are gettting will be generated.
I believe your problem is the fact that you are trying to update all fields in your table with string values. If the fields in the table are not all strings then you will get the error you are geting.
I notice that there is a date field you are updating. If this field is a date field and the value you are supplying is not in a valid date format, then the error you are gettting will be generated.
•
•
Join Date: May 2009
Posts: 8
Reputation:
Solved Threads: 0
Dear Vandamn,
Thanks for your fast valuable response. I'm sure that I put valid date entries in both birthdate and hiring date,
Yes you are right, I think vb considers any input from textboxes as string, but what can I do?
How can I solve this problem? I tried to convert the "ID" to intiger in "Delete record code form" using Cint function but it doesn't work
it gave me the same error,
please help
Thanks for your fast valuable response. I'm sure that I put valid date entries in both birthdate and hiring date,
Yes you are right, I think vb considers any input from textboxes as string, but what can I do?
How can I solve this problem? I tried to convert the "ID" to intiger in "Delete record code form" using Cint function but it doesn't work

it gave me the same error,
please help
![]() |
Similar Threads
- VB 2008 Express Compact SQL UPDATE query error (VB.NET)
- Syntax error in UPDATE statement. (VB.NET)
- Syntax error on update database code (VB.NET)
- Syntax error in INSERT INTO statement (Java)
- MySQL/PHP UPDATE Syntax error (MySQL)
- MySQL syntax error check for the right syntax to use near 'A (A) )' at line 1 (PHP)
- UPDATE syntax error (MySQL)
Other Threads in the VB.NET Forum
- Previous Thread: Help needed in Converting C# Code to VB.Net Code
- Next Thread: Filter records
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net 30minutes 2005 2008 access account application arithmetic array arrays basic binary bing button buttons c# center check checkbox code combobox component connectionstring convert crystalreport data database databasesearch datagrid datagridview design dissertation dissertations dissertationthesis dropdownlist excel file-dialog folder ftp generatetags google gridview hardcopy image images inline insert intel internet listview mobile monitor ms net networking output passingparameters peertopeervideostreaming picturebox picturebox1 plugin port print printing problem problemwithinstallation project reports" save searchbox searchvb.net select serial server soap sorting table tcp text textbox timer toolbox trim update updown user vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web wpf





