G
Guest
SqlDataReader rdr = null;
SQLConnection con = null;
SqlCommand cmd = null;
try
{
// Open connection to the database
string ConnectionString = "server=localhost;database =
CallBilling 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();
}
This is part of the program and it goes like this this-->when the user enter
the customer id in the text box and press the button, it will search in the
table for the activities about that customer id and display out in the data
grid. I don't know how to match the value from the text box with the customer
id in the table and display out in the data grid....do i do anything
wrong?please correct my mistakes or any suggestion or coding
welcome....thanks..
SQLConnection con = null;
SqlCommand cmd = null;
try
{
// Open connection to the database
string ConnectionString = "server=localhost;database =
CallBilling 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();
}
This is part of the program and it goes like this this-->when the user enter
the customer id in the text box and press the button, it will search in the
table for the activities about that customer id and display out in the data
grid. I don't know how to match the value from the text box with the customer
id in the table and display out in the data grid....do i do anything
wrong?please correct my mistakes or any suggestion or coding
welcome....thanks..