注册 登录
编程论坛 VB6论坛

开发网络版软件用VB如何的连接sqlserver2000数据库 请各位大虾指教!!!!!

武越 发布于 2013-03-31 16:43, 644 次点击
求救!!! 加1028344078 xiexie
3 回复
#2
zsdtylj2013-04-12 12:47
Dim cn As New ADODB.Connection
cn.ConnectionString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=chengben;Data Source=192.168.0.2"
cn.Open
#3
chenzr2013-04-16 13:20
这样吧...

Private Function ConnectToDatabase() As Boolean
On Error GoTo ErrHandler
Dim Conn As ADODB.Connection, DBName As String, ServerAdd As String, UserName As String, UserPwd As String
UserName = "sa"
UserPwd = ""
DBName = "数据库名"
ServerAdd = "服务器IP"
Conn.ConnectionTimeout = 10
Conn.CursorLocation = adUseClient
Conn.ConnectionString = "uid=" & UserName & ";pwd=" & UserPwd & ";driver={SQL SERVER};server=" & ServerAdd & ";database=" & DBName & ";dsn=''"
Conn.Open
ConnectToDatabase = True
Exit Function
ErrHandler:
MsgBox "错误信息:" & Err.Description, vbCritical, "警告"
Exit Function
End Function
#4
jefferman2013-04-16 21:34
用ADO控件,点击下鼠标就连接上了
1