0

我不知道如何转换此代码。

此代码用于子主

Public Sub main()
    On Error Resume Next
    frmsplash.Show
    Open App.Path & "/joel.txt" For Input As #1
    Input #1, serverhost
    Input #1, mydatabasename
    Input #1, myusername
    Input #1, mypassword
    Input #1, mysqlport
    Close #1

    cn.ConnectionString = "Driver={MySQL ODBC 5.1 Driver};Server=" & Trim(serverhost) & ";Port=" & Trim(mysqlport) & ";Database=" & Trim(mydatabasename) & "; User=" & Trim(myusername) & ";Password=" & Trim(mypassword) & ";Option=3;"
    cn.Open

    If cn.State = 0 Then
        MsgBox "Unable  to connect to database", vbCritical
        frmconnect.Show
        frmsplash.Hide
    Exit Sub

以及用于创建连接的代码

Private Sub cmdcreate_Click()
    Open App.Path & "\joel.txt" For Output As #1
    Print #1, txtserver.Text
    Print #1, txtschema.Text
    Print #1, txtuser.Text
    Print #1, txtpassword.Text
    Print #1, txtport.Text
    Close #1
    Unload Me
    Call main
End Sub

我试图创建一个连接字符串.. submain.. 文本文件...

4

1 回答 1

0

用于system.io.textreader从文件中读取一行:

dim tr as system.io.textreader = new system.io.streamreader(file)
dim val as string = tr.readline

用于system.io.textwriter将一行写入文件:

dim tw as system.io.textwriter = new system.io.streamwriter(file)
tw.writeline(val)

至于数据访问,请使用 system.data 中的某些内容。你需要用谷歌搜索'因为我正在手机上写这个并且刚刚失去了耐心:-)

于 2013-03-12T16:54:15.173 回答