I have two tables pre_enquiry & enquiry ,enquiryno is primary key of pre_enquiry table,username is also stored in it.In enquiry webform if i enter username then related enquiryno. should be autofilled in textbox ,& delete the record from pre_enquiry table
Auto Complete
Collapse
X
-
Start your own thread. -
Hi Nilesh,
What have you tried so far to solve your problem?
Have you checked out the AutoComplete control available to you for free in the Ajax Tool Kit?
-FrinnyComment
-
I have done the following
i want to fetch EnquiryNo from Pre_enq table & assign the value to TxtEnqNo textboxCode:protected void TextBox1_TextChanged(object sender, EventArgs e) { where(Uname="+TextBox1.Text+")"); int i; cn1 = new SqlConnection(ConfigurationManager.ConnectionStrings["BruserConnectionString2"].ConnectionString); cmd = new SqlCommand("select EnquiryNo from Pre_Enquiry where(Uname=@uname);", cn1); cn1.Open(); SqlDataReader tr; tr=cmd.ExecuteReader(); while (tr.Read()) { i = Convert.ToInt32(tr["EnquiryNo"]); TxtEnqNo.Text = Convert.ToString(i); //TxtEnqNo.Text=cmd.Parameters.Add("@EnquiryNo").Value; } tr.Close(); cn1.Close(); }Last edited by Frinavale; Mar 10 '09, 01:04 PM. Reason: Added [code] tags: Please post code in [code] [/code] tagsComment
-
You aren't supplying the parameter to the sql command...
Code:protected void TextBox1_TextChanged(object sender, EventArgs e) { where(Uname="+TextBox1.Text+")"); int i; cn1 = new SqlConnection(ConfigurationManager.ConnectionStrings["BruserConnectionString2"].ConnectionString); cmd = new SqlCommand("select EnquiryNo from Pre_Enquiry where(Uname=@uname);", cn1); //Note the following line...... cmd.Parameters.Add("@uname", SqlDbType.varChar).Value = TextBox1.Text cn1.Open(); SqlDataReader tr; tr=cmd.ExecuteReader(); while (tr.Read()) { i = Convert.ToInt32(tr["EnquiryNo"]); TxtEnqNo.Text = Convert.ToString(i); //TxtEnqNo.Text=cmd.Parameters.Add("@EnquiryNo").Value; } tr.Close(); cn1.Close(); }Comment
Comment