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

...全文
239 5 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
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,故,你无须指定用什么驱动了)
北京的雾霾天 2004-10-27
  • 打赏
  • 举报
回复
如果是连SqlServer就是用第三个,它不用也不能指定provider.

111,096

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • AIGC Browser
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

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

试试用AI创作助手写篇文章吧