error:datatype mismatch
-
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
string str = "Select * From Vendor Where(VendorID= '"+ DropDownList1.SelectedValue +"')";
OleDbCommand cmd = new OleDbCommand(str, conn);
OleDbDataReader dr=null;
conn.Open();
dr = cmd.ExecuteReader();
while (dr.Read())
{
txtvendorname.Text = dr["VendorName"].ToString();
}
conn.Close();
}hi i am getting data type mismatch error on executin this code.plz guide...
mylogics wrote:
string str = "Select * From Vendor Where(VendorID= '"+ DropDownList1.SelectedValue +"')";
check whether VendorID is int or string, if VendorID is int then use "DropDownList1.SelectedValue" if VendorID is string then use '"DropDownList1.SelectedValue"'
Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]
-
mylogics wrote:
string str = "Select * From Vendor Where(VendorID= '"+ DropDownList1.SelectedValue +"')";
check whether VendorID is int or string, if VendorID is int then use "DropDownList1.SelectedValue" if VendorID is string then use '"DropDownList1.SelectedValue"'
Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]
-
actually m using access database n the vendorID datatype is autonumber previously when the vendorID was text it was workin f9.... wat shud i do... ERROR:DATATYPE MISMATCH IN CRITERIA EXPRESSION
then remove single quotes and try
Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]
-
actually m using access database n the vendorID datatype is autonumber previously when the vendorID was text it was workin f9.... wat shud i do... ERROR:DATATYPE MISMATCH IN CRITERIA EXPRESSION
You can try this -
string str = "Select * From Vendor Where(VendorID= "+ DropDownList1.SelectedValue +")";
Regards, Arindam Sinha MyBlog - http://arindamsinha.wordpress.com/ Please give your feedback on this answer.
-
then remove single quotes and try
Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]
-
it gives error while compiling.i think the problem is with dtatype of vendorID.previously when datatype was text it worked f9.
what is the error... what is the value you got in the dropdown selected value....
Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]
-
what is the error... what is the value you got in the dropdown selected value....
Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]
-
it will render in back end as, select * from table where id is '2'-- this is wrong because ''is for string...... so we have to mention as, select * from table where id is 2 and for name field, select name from table where name = 'xyz'-- this is correct
Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]
-
it will render in back end as, select * from table where id is '2'-- this is wrong because ''is for string...... so we have to mention as, select * from table where id is 2 and for name field, select name from table where name = 'xyz'-- this is correct
Padmanabhan My Articles: Articles[^] My latest Article: Word Automation[^]
-
One small suggestion..The when you build a query string try to execute that in the DB first. With quotes query would have given you the error in DB itself.
Regards, Arindam Sinha MyBlog - http://arindamsinha.wordpress.com/ Please give your feedback on this answer.
-
One small suggestion..The when you build a query string try to execute that in the DB first. With quotes query would have given you the error in DB itself.
Regards, Arindam Sinha MyBlog - http://arindamsinha.wordpress.com/ Please give your feedback on this answer.