Monday, April 13, 2015

insert data in SQL SERVER database in ASP.NET

//.cd file

 SqlConnection con = new           SqlConnection(ConfigurationManager.ConnectionStrings["str"].ConnectionString);

 SqlCommand cmd;

cmd = new SqlCommand("insert into student values(@fnames,@lname)", con);
        cmd.CommandType = CommandType.Text;
        cmd.Parameters.AddWithValue("@fnames""some values");
        cmd.Parameters.AddWithValue("@lname""some values");

        con.Open();
        cmd.ExecuteNonQuery();

        con.Close();

No comments:

Post a Comment