Saturday, March 10, 2018

Insert C# SQL/Connection String

string strSQL1;
            strSQL1 = "   insert into [tblcontrol_Comt] ( [SLNO],[Status],[Reason]) select " + t1 + ",'" + DropDownList4.SelectedItem + "','" + TB_Comment.Text + "'";
            strSQL = strSQL + strSQL1;

            //Response.Write(strSQL);
            //Response.End();


            SqlCommand cmd = new SqlCommand(strSQL, myConnection);
            cmd.CommandTimeout = 30000;
            cmd.CommandType = CommandType.Text;
            myConnection.Open();
            cmd.ExecuteNonQuery();
            myConnection.Close();


 private string ConnectionString
    {
        get
        {
            string connectionString = ConfigurationManager.ConnectionStrings["ConnectionString1"].ConnectionString;
            return connectionString;
        }
    }


On Sat, Mar 10, 2018 at 10:42 PM, Rajeev Kumar <rajeevkum@gmail.com> wrote:
 string strSQL1;
            strSQL1 = "   insert into [tblcontrol_Comt] ( [SLNO],[Status],[Reason]) select " + t1 + ",'" + DropDownList4.SelectedItem + "','" + TB_Comment.Text + "'";
            strSQL = strSQL + strSQL1;

            //Response.Write(strSQL);
            //Response.End();


            SqlCommand cmd = new SqlCommand(strSQL, myConnection);
            cmd.CommandTimeout = 30000;
            cmd.CommandType = CommandType.Text;
            myConnection.Open();
            cmd.ExecuteNonQuery();
            myConnection.Close();



--
Rajeev Kumar
949-378-6094

No comments: