When I try(string search = textBox1.Text.ToString();) to search a row from access database it says to me "Mismatched datatype ON access the type is ShortText?
Loading
When I try(string search = textBox1.Text.ToString();) to search a row from access database it says to me "Mismatched datatype ON access the type is ShortText?
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sachin SinghRank #66 · 26.2K reputationPosted Oct 18, 2021, 1:36 AM EDT
Rijwan AnsariRank #82 · 24.2K reputationPosted Oct 18, 2021, 7:40 AM EDT
Srinivasan RamamoorthiRank #877 · 2.5K reputationPosted Oct 18, 2021, 7:52 AM EDT
Try to get the select query from C# watch window and run it against ACCESS database to check the issue.
NURU DAWUD199 reputationPosted Oct 18, 2021, 2:30 PM EDT
System.Data.OleDb.OleDbException: 'Data type mismatch in criteria expression.'
code sample
public void search()
{
string search = Convert.ToString(txtSearch.Text);
con = new ConnectionClass();
con.oledbquery("select * from tableuser where primarykey = " +search+" ") ;
con.d2 = con.cmd.ExecuteReader();
// con.queryex();
while (con.d2.Read())
{
weredaId_47.Text = con.d2[0].ToString();
regBookNo_1.Text = con.d2.GetString(1);
birthRegBookNo_2.Text = con.d2.GetString(2);
regOfficeNo_3.Text = con.d2.GetString(3);
birthRegIdNo_4.Text = con.d2.G
}
}
Sachin SinghRank #66 · 26.2K reputationPosted Oct 19, 2021, 12:18 AM EDT