vb6,adodb with sql server 2008 [英] vb6,adodb with sql server 2008
问题描述
因为我是sb server 2008的vb6新手。我设法在项目文件夹中创建名为:Tuscan77的数据库,其中包含表中主键和外键的所有必需表。我已经在vb6中使用带有ms访问权限的adodb完成了相同的项目,并且我已经完成了
。但现在基于我的老板订单,我必须将vb6与adodb连接到sql server 2008。
现在,下面是我在vb6中的mdi父表单中的代码,我用它连接到访问数据库。:
Dim i As Integer
Dim AccessConnect As String
Dim dBOOL As Boolean
Dim dMstr As String
If(Left(App.Path,1)=" \")然后
dMstr = Dir(App.Path&" tuscanDB.mdb")
Else
dMstr = Dir(App.Path&" \tuscanDB.mdb")
End if
dBOOL = IIf(dMstr ="",False,True)
If(dBOOL)Then
AccessConnect =" Driver = {Microsoft Access Driver(* .mdb)};" &安培; _
" Dbq = tuscanDB.mdb;" &安培; _
" DefaultDir =" &安培; App.Path&英寸;" &安培; _
"Uid = Admin; Pwd =;"
如果(adoDatabase.State<> 0)那么
adoDatabase.Close
结束如果
adoDatabase.ConnectionString = AccessConnect
adoDatabase.Open
Else
Dim mPath As String
CommonDialog1.CancelError = True
CommonDialog1.Flags = cdlOFNHideReadOnly + cdlOFNPathMustExist + cdlOFNFileMustExist
'设置过滤器
CommonDialog1.Filter =" ;所有文件(*。*)| *。* | RTF(* .rtf)| * .rtf |文本文件(* .txt)| * .txt"
'显示保存对话框
CommonDialog1.FileName =""
CommonDialog1.ShowOpen
dMstr = Dir(CommonDialog1.FileName)
mPath = Left(CommonDialog1.FileName,InStr(mPath,dMstr) - 2)
If( CommonDialog1.CancelError = False)然后
AccessConnect =" Driver = {Microsoft Access Driver(* .mdb)};" &安培; _
" Dbq =" &安培; dMstr&英寸;" &安培; _
" DefaultDir =" &安培; mPath&英寸;" &安培; _
"Uid = Admin; Pwd =;"
'---------------------------
'连接对象方法
' - --------------------------
adoDatabase.ConnectionString = AccessConnect
adoDatabase.Open
结束如果
结束如果
}
其中adoDatabase是vb6中我的连接名称,带有ms访问权限的adodb。
现在我如何将vb6,adodb与sql server 2008连接?
现在我的sql server 2008详细信息:
服务器类型:数据库引擎
服务器名称: NPD-4 \SQLEXPRESS
身份验证:Windows身份验证
用户名:NPD-4 \ TUSCANO
<密码:(它留空或不必要)
数据库名称:Tuscan77
如何在vb6中连接名为Tuscan77的数据库ADODB?任何人都可以帮助我。非常感谢任何帮助或指导。
您好,
在以下论坛中发布所有与vb6相关的查询会更合适。
http://www.vbforums.com/forumdisplay.php?1- Visual-Basic-6-and-early !!
http://forums.codeguru.com/forumdisplay.php?4-Visual-Basic-6-0-Programming
hi for i am new to vb6 with sql server 2008. I have managed to create database named : Tuscan77 in project folder with all the necessary tables with primary and foreign keys in tables. I have done the same project in vb6 with adodb with ms access and i have finished it. But now based on my boss orders i have to connect vb6 with adodb with sql server 2008.
Now below is my code in mdi parent form in vb6 which i used to connect to database in access.:
Dim i As Integer Dim AccessConnect As String Dim dBOOL As Boolean Dim dMstr As String If (Left(App.Path, 1) = "\") Then dMstr = Dir(App.Path & "tuscanDB.mdb") Else dMstr = Dir(App.Path & "\tuscanDB.mdb") End If dBOOL = IIf(dMstr = "", False, True) If (dBOOL) Then AccessConnect = "Driver={Microsoft Access Driver (*.mdb)};" & _ "Dbq=tuscanDB.mdb;" & _ "DefaultDir=" & App.Path & ";" & _ "Uid=Admin;Pwd=;" If (adoDatabase.State <> 0) Then adoDatabase.Close End If adoDatabase.ConnectionString = AccessConnect adoDatabase.Open Else Dim mPath As String CommonDialog1.CancelError = True CommonDialog1.Flags = cdlOFNHideReadOnly + cdlOFNPathMustExist + cdlOFNFileMustExist ' Set filters CommonDialog1.Filter = "All Files (*.*)|*.*|RTF (*.rtf)|*.rtf|Text Files (*.txt)|*.txt" ' Display the Save dialog box CommonDialog1.FileName = "" CommonDialog1.ShowOpen dMstr = Dir(CommonDialog1.FileName) mPath = Left(CommonDialog1.FileName, InStr(mPath, dMstr) - 2) If (CommonDialog1.CancelError = False) Then AccessConnect = "Driver={Microsoft Access Driver (*.mdb)};" & _ "Dbq=" & dMstr & ";" & _ "DefaultDir=" & mPath & ";" & _ "Uid=Admin;Pwd=;" '--------------------------- ' Connection Object Methods '--------------------------- adoDatabase.ConnectionString = AccessConnect adoDatabase.Open End If End If }
where adoDatabase is name of my connection in vb6 with adodb with ms access.
Now how i connect vb6,adodb with sql server 2008?
Now my sql server 2008 details:
Server type: Database Engine
Server name: NPD-4\SQLEXPRESS
Authentication: Windows authentication
User name: NPD-4\TUSCANO
password:(it is left blank or not necessary)
Database name: Tuscan77
How to i connect my Database named Tuscan77 in vb6 and adodb.? Can anyone help me please.Any help or guidance would be greatly appreciated.
Hi,
It would be more appropriate to post all your vb6 related queries in the below forums.
http://www.vbforums.com/forumdisplay.php?1-Visual-Basic-6-and-Earlier
http://forums.codeguru.com/forumdisplay.php?4-Visual-Basic-6-0-Programming
这篇关于vb6,adodb with sql server 2008的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!