|
这就是获取用户名密码的子程序,你可以直接用你的方式获取或者直接写进程序里。我的你不一定适用。我GetAccount取得用户名密码是存在MySQL数据库里的。下面供参考。
Sub GetAccount_test(UserName As Variant, Password As Variant)
'从路径文件中获取文件路径
UserName = "CNYAZHA11"
Password = "zZ567890"
End Sub
Sub GetAccount_Txt(UserName As Variant, Password As Variant)
'从路径文件中获取文件路径
Dim StrLine As String
Open ThisWorkbook.Path & "\settings\account.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, StrLine
If InStr(StrLine, "UserName:") Then
UserName = Trim(Replace(StrLine, "UserName:", ""))
ElseIf InStr(StrLine, "Password:") Then
Password = Trim(Replace(StrLine, "Password:", ""))
End If
Loop
Close #1
End Sub
Sub GetAccount_xls(UserName As Variant, Password As Variant)
Set ShtST = Sheets("settings")
With ShtST
UserName = Trim(.Range("B1").Value)
Password = Trim(.Range("B2").Value)
End With
End Sub
Sub GetAccount(UserName As Variant, Password As Variant)
Dim con_str, sql_str, Str, rs, Cnn
Set rs = CreateObject("ADODB.recordset")
Set Cnn = CreateObject("ADODB.Connection")
con_str = MESConnString
sql_str = "SELECT config_value FROM sln_index.z_config where config_key = ""ProdOrder_GetInfoFromSAP"""
Cnn.Open (con_str)
rs.Open sql_str, Cnn
Str = rs.getrows
UserName = Mid(Str(0, 0), 18, 8)
Password = Mid(Str(0, 0), 44, 8)
End Sub |
|