SqlConnection con=new SqlConnection(...);
SqlCommand cmd=new SqlCommand();
cmd.Connection=con;
cmd.CommandText="insert into users values(@id,@name,@sex,@borthday)";
cmd.Parameters.Add("@id",SqlDbType.VarChar,10);
cmd.Parameters.Add("@name",SqlDbType.VarChar,10);
cmd.Parameters.Add("@sex",SqlDbType.Char,2);
cmd.Parameters.Add("@borthday",SqlDbType.Date,0);
cmd.Parameters[0].Value="001";
cmd.Parameters[1].Value="liz";
cmd.Parameters[2].Value="男";
cmd.Parameters[3].Value="1999-9-9";
try
{
con.Open();
cmd.ExecuteNonQuery();
con.Close();
}
catch{}