日期:2014-05-17 浏览次数:20930 次
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=data;User ID=sa;password=sa;Integrated Security=False");
//参数化sql语句
public void InSertData(string s1,string s2, string s3)//插入数据库
{
string sql = "insert into table(cpno,企业id,车辆型号) ";
sql += "values(@cpno, @企业id, @车辆型号)";
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = sql;
cmd.Parameters.AddWithValue("@cpno", s1);
cmd.Parameters.AddWithValue("@企业id", s2);
cmd.Parameters.AddWithValue("@车辆型号", s3);
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
}
}
private void button1_Click(object sender, EventArgs e)
{
DataSet ds = getdata();//你的dataset
try
{
&n