Asp tutorial. net access database tutorial connection string summary
1. access database connection string. Configure the access file in the web. config file.
<Add key = "conn" value = "provider = microsoft. jet. oledb.4.0; data source ="/>
<Add key = "source" value = "app_databbs.mdb"/>
String constring = configurationmanager. apps tutorial ettings ["conn"] + httpcontext. current. server. mappath ("~ ") + Configurationmanager. Receivettings [" source "];
2. The access database is sensitive to keywords. For keywords such as password, brackets must be added for query. Otherwise, an error is returned.
String querystring = "insert into users ([username], [password], [gendor], [createtime]) values (@ username, @ password, @ gendor, @ createtime )";
3. For date fields, convert them to strings and then to dates.
Oledbparameter par = new oledbparameter ("@ createtime", convert. todatetime (userinfo. createtime. tostring ());
4. access database parameters are strictly ordered. If the order of parameters is incorrect, no error is reported during execution, but no insert or update operations are performed, which will not affect the database.
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)}; // If you write the id parameter before it, the execution will not succeed.