Click here to Skip to main content
15,921,548 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
how can solve this qurrey this code is well performed but..i need when i insert any name it fill all the information of that client in textbox plz help

What I have tried:

<pre>
            SqlConnection con = new SqlConnection(@"Data Source=AQSASHAIKH\SQLEXPRESS;Initial Catalog=Client;Integrated Security=True");
            string com = "Select * From [dbo].[client]";
            SqlDataAdapter da = new SqlDataAdapter(com, con);
            DataTable dt = new DataTable();
            da.Fill(dt);
            DropDownList1.DataSource = dt;
            DropDownList1.DataBind();
            DropDownList1.DataTextField = "Name";
            DropDownList1.DataValueField = "id";
            DropDownList1.DataBind();
            SqlConnection Conn = new SqlConnection(@"Data Source=AQSASHAIKH\SQLEXPRESS;Initial Catalog=Client;Integrated Security=True");
            SqlCommand Comm1 = new SqlCommand(com, Conn);
            Comm1.Connection = Conn;
            Comm1.CommandText = "SELECT COUNT(*) FROM client";
            Conn.Open();
            TxtBox1.Text = Comm1.ExecuteScalar().ToString();
            TxtBox2.Text = Comm1.ExecuteScalar().ToString();
            Conn.Close();
Posted
Updated 2-Oct-20 3:53am
Comments
OriginalGriff 2-Oct-20 8:02am    
And?
What does it do that you didn't expect, or not do that you did?
What have you tried to do to find out why?
Are there any error messages, and if so, where and when? What did you do to make them happen?

This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with.
Use the "Improve question" widget to edit your question and provide better information.
Member 14954114 2-Oct-20 8:09am    
i trying to do is how can i am adding database value by name on textbox
on it

1 solution

If you want to save data to a database, you should use an insert SQL command and use ExecuteNonQuery to execute the command. You should read this[^] article first so that you build secure SQL that isn't open to SQL Injection attacks.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900