How to Display Data from Sql Server 2000 in windows application
Hi all,im back with yet another problem,i have three tables in my database : customer_info,dealer_info,client_info.I developed a form(Windows application),which includes 3 gridview controls displaying data of 3 tables..The problem is tht i need to display data of 3 tables simultaneously as i type my query into a textbox...hope ppl undertsand my problem and waiting eagerly for a response...Tahnks in advance.
Sunny ChenPosted Apr 7, 2008, 7:39 AM
I think putting queries into the TextBox OnChange event would be time consuming, maybe some other patterns can be adapted to this situation. Can we create a new thread that is handling the query and use the input buffer which could be filled by TextBox OnChange event as the inputting?
Bechir BejaouiPosted Apr 7, 2008, 6:34 AM
Bechir BejaouiPosted Apr 7, 2008, 6:32 AM
well;
implement the textbox_TextChanged with the following code
private void textBox1_TextChanged(object sender, EventArgs e)
{
SqlParameter oTextValue;
oTextValue = textBox1.Text;
SqlConnection oConnection = new SqlConnection("...");//Put your connection string instead of ...
SqlCommand oCommand = new SqlCommand("Select... Where Field = @myValue", oConnection);
/* You can modifiy the type SqlDbType.NVarChar to fit your needs Of Corse
* just a select NVarChar as an example*/
oTextValue = new SqlParameter("@myValue", System.Data.SqlDbType.NVarChar);
oCommand.Parameters.Add(oTextValue);
}