protected void cmdAdd_Click(object sender, EventArgs e) { clsCustomer DB = new clsCustomer(); try { if (txtCustomerid.Text == null) { lblResults.Text = "Please enter the customer number"; return; } if (txtCustomerName.Text == null) { lblResults.Text = "Please enter the customer name"; return; } if (txtAddress.Text == null) { lblResults.Text = "Please enter the location"; return; } int reccount = 0; reccount = DB.FindRecKount(txtCustomerid.Text); if (reccount > 0) { lblResults.Text = "Record already exists!!!"; return; } DB.Add_rec(txtCustomerid.Text, txtCustomerName.Text, txtAddress.Text, txtTelephoneNo.Text); //public string Add_rec(String txtCustomerid, String txtCustomerName, String txtAddress,String txtTelephoneNo) Define the ADO.NET objects. //string connectionString = //connectionString = WebConfigurationManager.ConnectionStrings["FleetConnectionString"].ConnectionString; //string selectSQL = "SELECT * FROM tb_Customer ORDER BY convert(int,customerno)"; //SqlConnection con = new SqlConnection(connectionString); //SqlCommand cmd = new SqlCommand(selectSQL, con); //SqlDataAdapter adapter = new SqlDataAdapter(cmd); // Fill the DataSet. DataSet ds = new DataSet(); ds = DB.FindTable(); //adapter.Fill(ds, "tb_Customer"); // Perform the binding. GridView1.DataSource = ds; GridView1.DataBind(); lblResults.Text = "Operation successful"; txtCustomerid.Text = ""; txtCustomerName.Text = ""; txtAddress.Text = ""; txtTelephoneNo.Text = ""; return; } catch (Exception err) { EventLog log = new EventLog(); log.Source = "Micar System"; log.WriteEntry(err.Message, EventLogEntryType.Error); return; } finally { //con.Close(); } }