Dim Conn as new SqlConnection("Data Source=数据库IP地址;Uid=用户名;pwd=密码;Initial CataLog=数据库名称")
Conn.Open() '以上为连接sql Server数据库
Dim Cmd as new SqlCommand("insert into 表名(字段1,字段2) value ('值1','值2')",Conn)
完全是这样用的啊!就是不知道为什么编辑器就告诉我只有一个参数。
to cnhgj(戏子):
Dim Conn as new SqlConnection("Data Source=数据库IP地址;Uid=用户名;pwd=密码;Initial CataLog=数据库名称")
Conn.Open() '以上为连接sql Server数据库
Dim Cmd as new SqlCommand("insert into 表名(字段1,字段2) value ('值1','值2')",Conn)
为什么我在*.vb里用SqlCommand()这个函数时他没后面的参数啊?
我看了书,也和你的代码差不多,就是因为有问题,才不知怎么做了呢!
它的提示是SqlCommand("一个字符串"),没后面的参数了啊!
Dim Conn as new SqlConnection("Data Source=数据库IP地址;Uid=用户名;pwd=密码;Initial CataLog=数据库名称")
Conn.Open() '以上为连接sql Server数据库
Dim Cmd as new SqlCommand("insert into 表名(字段1,字段2) value ('值1','值2')",Conn)
Cmd.ExecuteNonQuery() '插入数据
Dim Cmd as new SqlCommand("delete from 表名 where 字段1='值1')",Conn)
Cmd.ExecuteNonQuery() '删除数据