string strConnection="Provider=Microsoft.Jet.OleDb.4.0;Data Source=";
strConnection+=Server.MapPath(strDb);
OleDbConnection objConnection=new OleDbConnection(strConnection);
OleDbCommand objCommand = new OleDbCommand("这里是SQL语句" , objConnection);
objConnection.Open();
OleDbDataReader objDataReader=objCommand.ExecuteNonQuery();
dim objConnection as OleDbConnection
dim objCommand as OleDbCommand
objConnection=new OleDbConnection(Provider=Microsoft.Jet.OleDb.4.0;Data Source="+Server.MapPath(strDb))
objCommand=new OleDbCommand("这里是SQL语句" , objConnection)
objConnection.Open()
objDataReader=objCommand.ExecuteNoQuery()
下面再举例子说明一下SQL语句(ACCESS):
添加记录: insert int
o 表名 (字段1,字段2) values (字符串1,字符串2) where 条件
删除记录: delete from 表名 where 条件
修改记录: update 表名 set 字段1=××,字段2=×× where 条件
需要特别注意,如果是Sql Server删除记录是delete 表名,不需要再加from了。
文章来源于领测软件测试网 https://www.ltesting.net/