标题:VB连servers 2000问题
只看楼主
yamladdycx
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-9-25
 问题点数:0 回复次数:1 
VB连servers 2000问题
最近想弄个vb数据库,结果还没开始就碰钉子了。
Public conn As New ADODB.Connection
Public re As New ADODB.Recordset
Public addFlage As Boolean

Public Function opencn() As Boolean
Dim mag As String
On Error GoTo strerrmag
Set conn = New ADODB.Connection
conn.ConnectionTimeout = 25
conn.Provider = "sqloledb"
conn.Properties("initial catalog").Value = xzh '服务器名字
conn.Properties("integrated security").Value = "sellsystem" '库名
conn.Properties("user id").Value = "sa"
conn.Properties("password").Value = "sa"
conn.Open
opencn = True
addflag = ture
Exit Function
strerrmag:
    mag = "data can't connect"
    Call MsgBox(mag, vbOKOnly, "error:data connect")
    addflag = False
    Exit Function
   
End Function

Private Sub Command1_Click()
Call opencn
End Sub
这是代码,本人绝对没有写错,就是连不上,而且用ADO能够连上那个数据库。郁闷死,在CSDN上挂了半天没个好答复。希望这里能帮我解决问题
搜索更多相关主题的帖子: servers 
2008-09-25 20:39
三断笛
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:31
帖 子:1621
专家分:1617
注 册:2007-5-24
得分:0 
应该是这样子的,仔细看一下属性名对应的值.
conn.Provider = "sqloledb"
conn.Properties("Data Source").Value = "xzh" '服务器名字,引号要一个吧?
conn.Properties("initial catalogValue = "sellsystem" '库名
conn.Properties("user id").Value = "sa"
conn.Properties("password").Value = "sa"
conn.Open

一般就直接一句:

conn.open "Provider=SQLOLEDB.1;Password=密码;Persist Security Info=True;User ID=用户名;Initial Catalog=数据库名;Data Source=服务器地址"
2008-09-26 01:35



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-235183-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.133752 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved