日期:2014-05-18  浏览次数:20425 次

哪位大虾知道?ADO连接数据库问题?得到答案后立即结帐!!!!
哪位大虾碰到过这种情况:存储过程执行很快,大概5-7秒就能结束,但放到VB6.0调用后就很慢,有时候就会超过5分钟,这个存储过程要参照一个远程服务器中两个表中的数据,在网上搜索说有可能是ADO和服务器连接冲突引起的。具体不知道?请哪位大虾指点!在线等!!!!!或加我MSN:laozhang700@yahoo.com.cn


------解决方案--------------------
通过一个转换器(ADO),查询速度慢是肯定的.
但这么慢是肯定有问题的.帮顶.
------解决方案--------------------
Dim cn As New ADODB.Connection

' Connection to SQL Server without using ODBC data source.
cn.Open "Driver={SQL Server};Server=Server1;Uid=SA;Pwd=;Database=northwind"

cn.Close



---or 


' Initialize variables.
Dim cn As New ADODB.Connection
Dim provStr As String

' Specify the OLE DB provider.
cn.Provider = "sqloledb"

' Specify connection string on Open method.
ProvStr = "Server=MyServer;Database=northwind;Trusted_Connection=yes"
cn.Open provStr

---- or

' Initialize variables.
Dim cn As New ADODB.Connection
. . .
Dim ServerName As String, DatabaseName As String, _
UserName As String, Password As String

' Put text box values into connection variables.
ServerName = txtServerName.Text
DatabaseName = txtDatabaseName.Text
UserName = txtUserName.Text
Password = txtPassword.Text

' Specify the OLE DB provider.
cn.Provider = "sqloledb"

' Set SQLOLEDB connection properties.
cn.Properties("Data Source").Value = ServerName
cn.Properties("Initial Catalog").Value = DatabaseName

' Decision code for login authorization type: 
' Windows NT or SQL Server authentication.
If optWinNTAuth.Value = True Then
cn.Properties("Integrated Security").Value = "SSPI"
Else
cn.Properties("User ID").Value = UserName
cn.Properties("Password").Value = Password
End If

' Open the database.
cn.Open

------解决方案--------------------
尽管不明白你的问题!不过始终连接数据库是会影响效率的!还有数据库的用户数是有一定限制的,你始终不关闭访问会造成其他人访问不了的!