public void CallDB2(string strCodeSql, string msg) { try{ SqlConnection con = new SqlConnection(); // string s3 = "Data Source=.;Initial Catalog=db2;Integrated Security=true;"; //string s3 = @"provider=microsoft.jet.oledb.4.0;" + @"data source=..\\Debug\\db\\db2.mdb"; string str1 = ""; str1 = ConfigurationManager.ConnectionStrings["cn1"].ConnectionString; con = new SqlConnection(str1); SqlCommand cmd = new SqlCommand(strCodeSql, con); con.Open(); cmd.ExecuteNonQuery(); MessageBoxFrmEx.Show(msg); con.Close(); } catch (Exception er) { MessageBoxFrmEx.Show(er.Message.ToString(), "خطا "); } }
public void CallDB2(string strCodeSql, string msg) { try { SqlConnection con = new SqlConnection(); // string s3 = "Data Source=.;Initial Catalog=db2;Integrated Security=true;"; //string s3 = @"provider=microsoft.jet.oledb.4.0;" + @"data source=..\\Debug\\db\\db2.mdb"; string str1 = ""; str1 = ConfigurationManager.ConnectionStrings["cn1"].ConnectionString; con = new SqlConnection(str1); SqlCommand cmd = new SqlCommand(strCodeSql, con); con.Open(); cmd.ExecuteNonQuery(); MessageBoxFrmEx.Show(msg); con.Close(); // groupBox2.Enabled = false; // groupBox3.Enabled = false; // textBox1.Text = ""; // textBox2.Text = ""; } catch (Exception er) { // MsgBox.ShowMessage(this.Handle.ToInt32(), er.Message.ToString(), "خطا ", "تایید", "", "", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign); MessageBoxFrmEx.Show(er.Message.ToString(), "خطا "); } }