Hi,
I have one Textbox. In that textbox I have entered sometext. Now, my question is how to check that textbox's value to my database which I have created in Access on Button_Click event?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Krishna GaradPosted Apr 25, 2011, 4:33 AM
Public Bool CheckValue(string _value)
{
string _Sql="Select
SqlConnection cn=new SqlConnection("Connectionstring");
SqlCommand sqlcmd = new SqlCommand(_Sql, cn);
SqlDataReader sqldr = sqlcmd.ExecuteReader();
if (sqldr.HasRows)
return true;
else
return false;
}
May help you.
Sahil JaniPosted Apr 25, 2011, 5:01 AM
Thanks for your reply, I have tried your code first but I am getting some exception. After that I have tried the code given by Krishna, that is working fine in my project. Once again thanks for the reply.
Krishna GaradPosted Apr 25, 2011, 4:42 AM
Sahil JaniPosted Apr 25, 2011, 4:35 AM
Thanks for the reply but I have mentioned in my post that my database, which I have created in Access not in SQL.
Ankit NandekarPosted Apr 25, 2011, 4:13 AM
select * from tablename where studname='"+txtstudname.Text+"'
with the use of this query store data in dataset,and count rows of dataset like
if(ds.Tables[0].Rows.Count >0)
{
condition true then value is present inside database
}
else
{
value not present in database.
}