• 全部
  • C#综合技术
  • C#互联网桌面应用
  • AppLauncher
  • WinForm&WPF
  • C#开发新技术
  • 问答

C# 连接SQL server问题

fenghua2003 2004-10-27 11:38:52
1 string sConnectionString="provider=sqloledb;Data Source=localhost;Database=polaris;Uid=sa;Pwd=polaris;";

2 string sConnectionString="Driver={SQL Server};Server=localhost;Database=polaris;Uid=sa;Pwd=polaris;";

3 string sConnectionString="Initial Catalog=polaris;Data Source=localhost;User ID=sa;PWD=polaris";



我用3连接的时候没任何问题,用1连接的时候都提示不支持关键字"provider",用2的时候提示不支持关键字"Driver"

请问这是什么原因?我用的是windows 2003 server IIS6.0 Vs.net 2003

...全文
210 点赞 收藏 5
写回复
5 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
dengmain 2004-10-27
用SqlServer就不用什么provider等等的,因为它本身就是sql的驱动
回复
520NET 2004-10-27
LOOK THIS!
http://www.connectionstrings.com/
回复
hanbinghai 2004-10-27
看看这个网站,关于连接字符串的
http://www.connectionstrings.com/

Standard Security:

"Data Source=Aron1;Initial Catalog=pubs;User Id=sa;Password=asdasd;"
- or -
"Server=Aron1;Database=pubs;User ID=sa;Password=asdasd;Trusted_Connection=False"
(booth connection strings produces the same result)




Trusted Connection:

"Data Source=Aron1;Initial Catalog=pubs;Integrated Security=SSPI;"
- or -
"Server=Aron1;Database=pubs;Trusted_Connection=True;"
(booth connection strings produces the same result)

(use serverName\instanceName as Data Source to use an specifik SQLServer instance, only SQLServer2000)
Connect via an IP address:

"Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;Initial Catalog=pubs;User ID=sa;Password=asdasd;"
(DBMSSOCN=TCP/IP instead of Named Pipes, at the end of the Data Source is the port to use (1433 is the default))
Declare the SqlConnection:

C#:
using System.Data.SqlClient;
SqlConnection oSQLConn = new SqlConnection();
oSQLConn.ConnectionString="my connectionstring";
oSQLConn.Open();



VB.NET:
Imports System.Data.SqlClient
Dim oSQLConn As SqlConnection = New SqlConnection()
oSQLConn.ConnectionString="my connectionstring"
oSQLConn.Open()
回复
iamknight 2004-10-27
你用得是sqlConnection吧,该系列(sqlcommand,sqldataadapter等),只支持SqlServer,故,你无须指定用什么驱动了)
回复
如果是连SqlServer就是用第三个,它不用也不能指定provider.
回复
相关推荐
发帖
C#
创建于2007-09-28

10.5w+

社区成员

.NET技术 C#
申请成为版主
帖子事件
创建了帖子
2004-10-27 11:38
社区公告

让您成为最强悍的C#开发者