用vb6創建odbc為什麼不行?進入看代碼 ?

leotan_yang 2003-12-12 05:18:06
#If Win32 Then
Dim intRet As Long
#Else
Dim intRet As Integer
#End If
Dim strDriver As String
Dim strAttributes As String

'Set the driver to SQL Server because it is most common.
strDriver = "SQL Server"
'Set the attributes delimited by null.
'See driver documentation for a complete
'list of supported attributes.
strAttributes = "SERVER=(local)" & Chr$(0)
strAttributes = strAttributes & "DESCRIPTION=TempDSN" & Chr$(0)
strAttributes = strAttributes & "DSN=TEM" & Chr$(0)
strAttributes = strAttributes & "DATABASE=trade" & Chr$(0)
strAttributes = strAttributes & "UID=sa" & Chr$(0)
strAttributes = strAttributes & "PWD=" & Chr$(0)

'strAttributes = "SERVER=(local) DSN=ttt DATABASE=trade UID=sa"

'show dialog, use Form1.Hwnd instead of vbAPINull.
intRet = SQLConfigDataSource(vbAPINull, 4, strDriver, strAttributes)
If intRet Then
MsgBox "DSN Created"
Else
MsgBox "Create Failed"
End If
...全文
23 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
leotan_yang 2003-12-15
  • 打赏
  • 举报
回复
試過啦,系2000系統中,不是不行
yoki 2003-12-12
  • 打赏
  • 举报
回复
要用;分隔
'strAttributes = "SERVER=(local) DSN=ttt DATABASE=trade UID=sa"
改成
'strAttributes = "SERVER=(local);DSN=ttt ;ATABASE=trade;UID=sa"

即将 Chr$(0)改成";"

1,216

社区成员

发帖
与我相关
我的任务
社区描述
VB 数据库(包含打印,安装,报表)
社区管理员
  • 数据库(包含打印,安装,报表)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧