请问我的VB连接SQL中数据库代码哪里不对?谢谢!
请问我的VB连接SQL中数据库代码哪里不对?谢谢!Private Sub CmdLogoIn_Click()
Dim objcon As New ADODB.Connection
Dim strConn As String
Set objcon = New ADODB.Connection
strConn = "Provider=SQLOLEDB.1;Initial Catalog=123;Data Source=(local)"
objcon.Open strConn
End Sub
注:我的数据库名:123;用户名和密码都没有设置.
但运行时总出现:实时错误'-2147467259(80004005)':无效的授权说明 --------------------编程问答-------------------- Public Function ConnStr() As String
ConnStr = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=WIPTest;Data Source=TSONE"
End Function
參考一下 ,連接數據庫的Function --------------------编程问答-------------------- SQLOLEDB是.Net用的,VB6用下面的
Driver={SQL Server};Server=(local);Database=123;Uid=sa;Pwd=; --------------------编程问答-------------------- 谢谢! --------------------编程问答-------------------- Driver=SQL Server;Server=计算机名或IP地址;Database=数据库名;Uid=sa;Pwd=sa的密码; --------------------编程问答--------------------
Set Cn1 = New ADODB.Connection
ConnectStr = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=数据库名;Data Source=Local"
Cn1.Open ConnectStr, "sa", "sasa"
VB6中SQLOLEDB可以的
补充:VB , 数据库(包含打印,安装,报表)