????ASP.NET??C#??????????????????SQL Server??Access???????????????????????????????÷????????????????????????????????????????????????????????????????

????????Access

??????????????????????:

???????????:

using System.Data;
using System.Data.OleDb;
string strConnection="Provider=Microsoft.Jet.OleDb.4.0;";
strConnection+=@"DataSource=C:BegASPNETNorthwind.mdb";
OleDbConnection objConnection=new OleDbConnection(strConnection);
......
objConnection.Open();
objConnection.Close();
......

????????:

????????Access???????????????????????????????????????using???????????????!

????strConnection????????????????????????????????????????????????????????????????????????.

????"Provider=Microsoft.Jet.OleDb.4.0;"  2003??access ??????????????????????Microsoft Jet???棬???Access?е????????棬asp.net????????Access????????????.

????"Data Source=C:BegASPNETNorthwind.mdb"????????????λ??????????????"Data Source=MyDrive:MyPathMyFile.MDB".

???????

????1."+="?????"@"????????????????????е?""???????????.

????2.?????????????????????????????????£?????????????μ????????:

????strConnection+="Data Source=";  strConnection+=MapPath("Northwind.mdb"); ?????????????д?????????!

????3.??????????????е?????????÷???????.

????"OleDbConnection objConnection=new OleDbConnection(strConnection);"??????????????????????????????????????????????????????????????????????????.

????"objConnection.Open();"????????????.???????Access?????????????.???????(???????...)?????????鼮

????????SQL Server

??????????????:

???????????:

using System.Data;
using System.Data.SqlClient;
...
string strConnection="uid=sa;pwd=123;database=mydb;";
strConnection+="initial catalog=Northwind;Server=YourSQLServer;";
strConnection+="Connect Timeout=30";
SqlConnection objConnection=new SqlConnection(strConnection);
...
objConnection.Open();
objConnection.Close();
...

????????:

????????SQL Server???????????????Access?????????????????????????Connection???????????????е???????.

?????????????SQL Server?????????????"System.Data.OleDb"??????"System.Data.SqlClient".

?????????????????????????????????????????????(???:???????÷????):

????"user id=sa":???????????????????sa.?????????????"uid"??????????????????д??"uid=sa".

????"password=":????????????????????.????????"pwd"?????????????д?"pwd=".