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.
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
Krishna GaradRank #191 · 12.8K reputationPosted Apr 25, 2011, 12:33 AM EDT
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.
Ankit NandekarRank #703 · 3.4K reputationPosted Apr 25, 2011, 12:13 AM EDT
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.
}
Sahil Jani196 reputationPosted Apr 25, 2011, 12:35 AM EDT
Thanks for the reply but I have mentioned in my post that my database, which I have created in Access not in SQL.
Krishna GaradRank #191 · 12.8K reputationPosted Apr 25, 2011, 12:42 AM EDT
Sahil Jani196 reputationPosted Apr 25, 2011, 1:01 AM EDT
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.