最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp.net Access的数据库连接字符串总结
时间:2011-03-26 编辑:简简单单 来源:一聚教程网
1.access的数据库连接字符串。在web.config文件中配置access文件。
string constring = configurationmanager.apps教程ettings["conn"]+httpcontext.current.server.mappath("~")+configurationmanager.appsettings["source"];
2.access数据库对关键字敏感,对于password这样的关键字,需要加括号进行查询,否则会报错。
string querystring="insert into users([username],[password],[gendor],[createtime]) values(@username,@password,@gendor,@createtime)";
3.对于日期类型的字段,需要先转换为字符串,再转化为日期。
oledbparameter par=new oledbparameter("@createtime",convert.todatetime(userinfo.createtime.tostring());
4.access数据库的参数有严格的顺序,如果参数的顺序不对的话,执行时不会报错,但是不会做插入或更新操作,对数据库不会产生任何影响。
string updatestring = "update users set [username]=@username,[password]=@password,[gendor]=@gendor where [id]=@id";
oledbparameter[] pars ={
new oledbparameter("@username",userinfo.username),
new oledbparameter("@password",userinfo.password),
new oledbparameter("@gendor",userinfo.gendor),
new oledbparameter("@id",userinfo.id)};//如果将id参数写在前面,执行不会成功
相关文章
- C#复制数组的两种方式及效率比较解读 10-24
- ASP.NET Identity用法解析 10-24
- ASP.NET MVC使用Identity增删改查用户介绍 10-24
- C语言中atoi函数模拟实现介绍 10-18
- .Net反向代理组件Yarp用法介绍 10-10
- .NET使用YARP通过编码方式配置域名转发实现反向代理教程 10-10