1、通过命令插入数据

SqlCommand sqlcmd=new SqlComand("insert into table ("iditem","nameitem","sexitem")values(@id,@name,@sex)",con)

2、创建参数

sqlcom.Paramaters.Add(new SqlParamater("@id",SqlDbType.Varchar,10));  即将插入数据库中id 的属性,必须和数据库iditem 的属性一致;

3、设置参数值

sqlcom.Paramaters("id").value="yangbo"

4、执行

sqlcom.ExecuteNonQuery();

相关文章:

  • 2021-07-25
  • 2022-12-23
  • 2022-12-23
  • 2021-10-08
  • 2021-09-05
  • 2021-08-11
  • 2021-10-27
猜你喜欢
  • 2021-11-14
  • 2021-12-13
  • 2021-04-07
  • 2021-12-13
  • 2021-11-15
  • 2022-12-23
相关资源
相似解决方案