change the following lines
string CommandText = "SELECT Cust_ID" +
" FROM Call_Details_Record Where Cust_ID = '" + MyTextBox.Text + "'";
This is not the preferred way to do this, but I don't want to overwhelm you
with details. You are clearly a novice.
May I suggest that you could really benefit from a training course, or a
book that would walk you through a complex example step-by-step?
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"alyssa" <(E-Mail Removed)> wrote in message
news:1975177A-5102-4014-B8C5-(E-Mail Removed)...
> my prog works like this...i had created a summary report form where there
> is
> a text box, data grid and a button. when the user enter the customer id in
> the text box and press the button, the data grid will show the particulars
> about that customer id only....may i know how to pass the value from that
> text box to the database and display the value? below are my part of my
> program:
>
> SqlDataReader rdr = null;
> con = null;
> SqlCommand cmd = null;
> try
> {
> // Open connection to the database
> string ConnectionString
> = "server=CPQ82156712159; database=Call Billing System";
> con = new SqlConnection(ConnectionString);
> con.Open();
> // Set up a command with the given query and associate
> // this with the current connection.
> string CommandText = "SELECT Cust_ID" +
> " FROM Call_Details_Record";
> cmd = new SqlCommand(CommandText);
> cmd.Connection = con;
> rdr = cmd.ExecuteReader();
> while(rdr.Read())
> {
> textBox1.Text = rdr["Cust_ID"].ToString();
>
> }
>
> }
> catch(Exception ex)
> {
> // Print error message
> MessageBox.Show(ex.Message);
> }
> finally
> {
> // Close data reader object and database connection
> if (rdr != null)
> rdr.Close();
>
> if (con.State == ConnectionState.Open)
> con.Close();
> }
> Please tell me what to do in a detail steps...thanks...ur help is much
> appreciated...