Vb6 文本框中的连接字符串

Vb6 文本框中的连接字符串,vb6,connection,Vb6,Connection,我是编程新手,我的问题是。我已将ado db连接字符串放入文本框中,如何调用该文本框?我正在用VB6创建我的程序,下面是我的代码 Private Sub lvButtons_H2_Click() On Error GoTo errtrap If Label47.Caption = "True" Then MsgBox "INITIAL SETTING FOR SHIP ACCOUNT IS BEING PERFORMED", vbOKOnly, "ABORT" Exit Sub End If D

我是编程新手,我的问题是。我已将ado db连接字符串放入文本框中,如何调用该文本框?我正在用VB6创建我的程序,下面是我的代码

Private Sub lvButtons_H2_Click()
On Error GoTo errtrap
If Label47.Caption = "True" Then
MsgBox "INITIAL SETTING FOR SHIP ACCOUNT IS BEING PERFORMED", vbOKOnly, "ABORT"
Exit Sub
End If
Dim conas As New ADODB.Connection, rs01 As New ADODB.Recordset, rsx1 As New ADODB.Recordset, RS9 As New ADODB.Recordset
conas.Connectio`enter code here`nString = Text1155.Text
conas.Open
Set RS9 = New ADODB.Recordset
    RS9.ActiveConnection = conas
    RS9.CursorType = 3
    RS9.LockType = 3
    RS9.Open ("SELECT  * FROM [SHIPACCOUNT].[dbo].[SPARE PART LIST BOND 29 MONTHLY] WHERE NAMECODE = " & Text2.Text & "")
    Set DataReport2.DataSource = RS9

    DataReport2.Sections("Section2").Controls.item("LABEL12").Caption = Text1.Text
    DataReport2.Sections("Section2").Controls.item("LABEL11").Caption = Text3.Text

    DataReport2.Sections("Section1").Controls.item("TEXT1").DataField = RS9![PARTSNAME].Name
    DataReport2.Sections("Section1").Controls.item("TEXT2").DataField = RS9![Price].Name
    DataReport2.Sections("Section1").Controls.item("TEXT3").DataField = RS9![unit].Name
    DataReport2.Sections("Section1").Controls.item("TEXT4").DataField = RS9![QTYAPPLY].Name
    DataReport2.Sections("Section1").Controls.item("TEXT5").DataField = RS9!QTYAPPROVE.Name
    DataReport2.Sections("Section1").Controls.item("TEXT6").DataField = RS9![AMOUNTAPPROVE].Name
    DataReport2.Sections("Section1").Controls.item("TEXT7").DataField = RS9![Date].Name


DataReport2.Show 1

Exit Sub
errtrap:
MsgBox Err.Description, vbCritical, "The system encountered an error"
End Sub

您可以将连接字符串作为参数传递给
connection.Open方法
例如(假设文本框的名称为
Text1155
):

(在vb6中调用Sub不需要括号) 你的代码看起来很正确

Dim conas As New ADODB.Connection

conas.Open Text1155.Text