ASP.NET C# ???? access sqlserver ?????
???????????? ???????[ 2013/9/2 10:28:31 ] ????????
????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=".
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11