Hi
this is my code for insert to database .... but it will stop and show a run time error in connection.Open();and CmdSql.ExecuteNonQuery();
NEED ur help to move forward here on
SqlConnection connection = new SqlConnection();
connection.ConnectionString = "Data Source=ASA-PC\\SQLEXPRESS; Initial Catalog=Material_database; User ID=sa;Password=sa;Integrated Security=false;Connect Timeout=10";
connection.Open();
{
SqlCommand CmdSql = new SqlCommand("INSERT INTO [mat_utiAndtrans](Project, Date, Team_Leader, Vendor, WO, Rate,Code,Qty,Officer,Remark) VALUES (@Project, @Date, @Team_Leader, @Vendor, @WO, @Rate,@Code,@Qty,@Officer,@Remark)", connection);
connection.Open();
CmdSql.Parameters.AddWithValue("@Project", txtproject.Text);
CmdSql.Parameters.AddWithValue("@Date", txtdte.Text);
CmdSql.Parameters.AddWithValue("@Team_Leader", txtTeamleader.Text);
CmdSql.Parameters.AddWithValue("@Vendor", txtvendor.Text);
CmdSql.Parameters.AddWithValue("@WO", txtwo.Text);
CmdSql.Parameters.AddWithValue("@Rate", txtrate.Text);
CmdSql.ExecuteNonQuery();
connection.Close();