-
[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
Alright, I'm having some really funky issue with this. I know it's a mismatch (obviously) and I want to know if the DevX community members can help me solve this issue. It's been annoying me a lot of late.
Code:
try{
libSQL myAddNewData = new libSQL();
String strRownum =(String.valueOf(jComboBoxLName.getSelectedItem()));
if (intChoice == 1){
myAddNewData.AddNewData("INSERT INTO CUSDATA (FIRSTNAME, LASTNAME, PHONE, SIN) VALUES ('"+ strUserData[intCount][0] +"','" + strUserData[intCount][1] + "','" + strUserData[intCount][5] + "','" + strUserData[intCount][8] + "')");
myAddNewData.AddNewData("INSERT INTO CUSLOCATION (ADDRESS, CITY, [POSTAL CODE], COUNTRY, PROVINCE) VALUES ('" + strUserData[intCount][2] + "','" + strUserData[intCount][3] + "','" + strUserData[intCount][4] + "','" +strUserData[intCount][6] + "','" + strUserData[intCount][7] + "')");
}
if (intChoice == 2){
myAddNewData.AddNewData("UPDATE CUSDATA SET FIRSTNAME = '" + jTextFieldFName.getText() + "', PHONE = '" + jTextFieldPh.getText() + "', SIN = '" + jTextFieldSIN.getText() + "' WHERE ID = '" + strRownum + "'");
myAddNewData.AddNewData("UPDATE CUSLOCATION SET ADDRESS='" + jTextFieldAddr.getText() + "', CITY = '" + jTextFieldCity.getText() +"', [POSTAL CODE] = '" + jTextFieldPC.getText() + "' WHERE ID = '" + strRownum + "'");
}
if (intChoice == 3){
myAddNewData.AddNewData("DELETE FROM CUSDATA WHERE ID = '" + strRownum + "'");
myAddNewData.AddNewData("DELETE CUSLOCATION WHERE ID = '" + strRownum + "'");
}
}catch(Exception e){
jTextArea1.append("SQLException: " + e.getMessage());
}
The error I get when I initiate the UPDATE command:
init:
deps-jar:
Compiling 1 source file to D:\devel\java\netbeans\Grade 12\SIN\build\classes
compile:
run:
Error: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
Error: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
BUILD SUCCESSFUL (total time: 36 seconds)
Here's a screenshot of my databases:


Thanks,
deltatux
-
"String strRownum ="
DB: ID = LongInt
Tried converting strRownum to Int before using for DB access?
-
The query would be right for all string fields, but for any numeric type, leave off the ', so change this:
Code:
"('"+ strUserData[intCount][0] +"'
to this:
Code:
"("+ strUserData[intCount][0] +"
for Date fields:
Code:
"(#"+ strUserData[intCount][0] +"#,"...
Last edited by dglienna; 06-10-2008 at 07:57 PM.
David CodeGuru Article: Bound Controls are Evil-VB6
CodeGuru Reviewer
2006 Dell CSP
2006, 2007 & 2008 MVP Visual Basic If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post! 
-
 Originally Posted by LitlGreyCells
"String strRownum ="
DB: ID = LongInt
Tried converting strRownum to Int before using for DB access?
My original code had that, it didn't work and then I tried my friend's code who's code is in string.
-
 Originally Posted by dglienna
The query would be right for all string fields, but for any numeric type, leave off the ', so change this:
Code:
"('"+ strUserData[intCount][0] +"'
to this:
Code:
"("+ strUserData[intCount][0] +"
for Date fields:
Code:
"(#"+ strUserData[intCount][0] +"#,"...
Thanks, I'll try that and see.
Similar Threads
-
By rdwagco2 in forum Database
Replies: 5
Last Post: 08-03-2005, 09:44 AM
-
Replies: 2
Last Post: 06-27-2003, 12:06 PM
-
By chiradip das in forum Careers
Replies: 0
Last Post: 02-14-2003, 10:41 AM
-
By chiradip das chiradip_rediffmail.com in forum Careers
Replies: 0
Last Post: 02-14-2003, 10:39 AM
-
Replies: 0
Last Post: 10-11-2002, 10:52 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|