G
Guest
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...
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...