请哪位大侠给我写一段VB6.0连接SQL SERVER的程序代码,要把情况写清楚,急用
展开全部
先声明个全局变量
Public Conn As ADODB.Connection
Dim CN As New ADODB.Connection
Connect = False
' CN.Provider = "Microsoft.Jet.OLEDB.4.0" 'access
CN.Provider = "sqloledb.1" 'sqlserver
CN.ConnectionTimeout = 5
CN.CursorLocation = adUseClient
CN.ConnectionString = "Initial Catalog=" & svr.database _
& ";Data Source=" & svr.svr _
& ";Password=" & svr.userpaw _
& ";Persist Security Info=True;" _
& "User ID=" & svr.userid & ";"
CN.Open
Set Conn = CN
svr.database 换成 数据库
svr.svr 换成 服务器
svr.userpaw 换成 登陆sql的的用户密码
svr.userid 换成 登陆sql的用户名 如sa
Public Conn As ADODB.Connection
Dim CN As New ADODB.Connection
Connect = False
' CN.Provider = "Microsoft.Jet.OLEDB.4.0" 'access
CN.Provider = "sqloledb.1" 'sqlserver
CN.ConnectionTimeout = 5
CN.CursorLocation = adUseClient
CN.ConnectionString = "Initial Catalog=" & svr.database _
& ";Data Source=" & svr.svr _
& ";Password=" & svr.userpaw _
& ";Persist Security Info=True;" _
& "User ID=" & svr.userid & ";"
CN.Open
Set Conn = CN
svr.database 换成 数据库
svr.svr 换成 服务器
svr.userpaw 换成 登陆sql的的用户密码
svr.userid 换成 登陆sql的用户名 如sa
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询