private void btnSaveCustomer_Click(object sender, EventArgs e) { //Get database connection information from DBConnection.cs DBConnection conString = new DBConnection(); string dbConnString; conString.MyProperty = ""; dbConnString = conString.MyProperty; //Check all fields from SafeInsert.cs SafeInsert safeInsert = new SafeInsert(); string firstIn = safeInsert.firstNameFix(firstNameIn.Text); string lastIn = safeInsert.lastNameFix(lastNameIn.Text); string phoneIn = safeInsert.cityFix(phoneNumberIn.Text); string streetIn = safeInsert.streetFix(StreetIn.Text); string cityIn = safeInsert.cityFix(CityIn.Text); string stateIn = safeInsert.stateFix(StateIn.Text); int zipIn = safeInsert.zipFix(Convert.ToInt32(ZipIn.Text)); string emailIn = safeInsert.emailFix(EmailIn.Text); }
private void button1_Click(object sender, EventArgs e) { //Get database connection information from DBConnection.cs DBConnection conString = new DBConnection(); string dbConnString; conString.MyProperty = ""; dbConnString = conString.MyProperty; //Check all fields from SafeInsert.cs SafeInsert safeInsert = new SafeInsert(); string phoneIn = safeInsert.cityFix(phoneNumberIn.Text); try { MySqlConnection connection = new MySqlConnection(dbConnString); connection.Open(); //open connection MySqlDataAdapter MyDa = new MySqlDataAdapter(); string SqlSelectAll = "Select * from customerdetails;"; MyDa.SelectCommand = new MySqlCommand(SqlSelectAll, connection); DataTable table = new DataTable(); //Setup Bindings to attach to DataGrid MyDa.Fill(table); BindingSource bSource = new BindingSource(); bSource.DataSource = table; //Fill grid dgView.DataSource = bSource; } catch (Exception) { MessageBox.Show("Error Connecting"); } }