SqlConnection conn = new Sqlconnection();
conn.ConnectionString = ConfigurationManager.ConnectionStrings["MywebsiteConnectionString"].ToString(); //连接数据库的字符串,一般写在webconfig里
conn.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = conn;
cmd.CommandText = "INSERT INTO 表名(字段名一,字段名二)VALUES(@参数一,@参数二)";
cmd.Parameters.Add("@参数一",SqlDbType.Char).Value = TextBox1.Text.Trim();
cmd.Parameters.Add("@参数二",SqlDbType.Char).Value = TextBox2.Text.Trim();
int var = cmd.ExecuteNonQuery(); //执行数据库命令
if(var>0) //判断数据库命令是否执行成功
{
Response.Write("");
}