Using textbox, button control to search database
I am beginning at C#. I am trying to write an application that connects, searches our database via ADO.NET and bind the values to textbox controls.
Sample Program: Enter customer ID in textbox1, click search button, and display values in textboxes. Problem that I am having is creating the entry point textbox code. Here is the code I have so far.
private void button3_Click(object sender, EventArgs e)
{
string select = "select * from customer where master_customer_id=" + textBox3.Text;
string source = @"Data Source=DB;database=TTST;User id=sa;Password=;";
SqlConnection conn = new SqlConnection(source);
conn.Open();
//Use SqlDataAdapter to fill rows to dataset
SqlDataAdapter da = new SqlDataAdapter(select, conn);
DataSet ds = new DataSet();
da.Fill(ds, "Customer");
//Binding Data to Textbox Control
textBox1.DataBindings.Add("Text", ds, "customer.first_name");
textBox2.DataBindings.Add("Text", ds, "customer.last_name");
}
I get the following error when I try to run and Enter in textbox3 - 000000000001, Click search
error:
Arithmetic overflow error converting numeric to data type numeric
|