Import System.Data.SqlClient;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() '删除数据
ASP.Net WebMatrix裏麵帶有編輯,刪除,添加的糢闆,妳可以拿來看看,他是直接連接sql-server的繫統錶的,所以可以直接運行。
加名空单 using system.data.sqlclient; using System.data.command; sring strconn="server=localhost;uid=sa;pwd=;database=你的SQL数据库名"; string strsql="SELECT * FROM jobs";//SQL SqlConnection conn=new sqlconnextion(strconn); SqlCommand comm=new sqlcommand(strsql,conn); conn.open(); comm.exenoeryquey(); conn.close(); comm.dispose();
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("一个字符串"),没后面的参数了啊!
忘了说了,是在win2k(sp4) + .net1.1下编辑的。
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) 完全是这样用的啊!就是不知道为什么编辑器就告诉我只有一个参数。
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() '删除数据
using system.data.sqlclient;
using System.data.command;
sring strconn="server=localhost;uid=sa;pwd=;database=你的SQL数据库名";
string strsql="SELECT * FROM jobs";//SQL
SqlConnection conn=new sqlconnextion(strconn);
SqlCommand comm=new sqlcommand(strsql,conn);
conn.open();
comm.exenoeryquey();
conn.close();
comm.dispose();
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("一个字符串"),没后面的参数了啊!
Conn.Open() '以上为连接sql Server数据库
Dim Cmd as new SqlCommand("insert into 表名(字段1,字段2) value ('值1','值2')",Conn)
完全是这样用的啊!就是不知道为什么编辑器就告诉我只有一个参数。