老师: 您好!我的代码如下:
If filesys.FileExists(projectPath & "config.ini") Then
Dim str1 As String = Filesys.ReadAllText(ProjectPath & "config.ini",system.text.encoding.default)
Dim str2() As String = Str1.Split(vblf)
Dim str3() As String
Dim zf1,zf2,zf3,zf4 As String
For i As Integer =1 To str2.length -1
str3 = str2(i).split("=")
If str3.length = 2 Then
If str3(0).contains("服务器名") Then
zf1 = str3(2)
ElseIf str3(0).contains("数据库名") Then
zf2 = str3(2)
ElseIf str3(0).contains("登录账户") Then
zf3 = str3(2)
ElseIf str3(0).contains("登录密码") Then
zf4 = str3(2)
End If
End If
Next
Dim CnString As String
If zf4 = "" Then
cnstring = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID= & zf3;Initial Catalog= & zf2;Data Source= & zf1"
ElseIf zf4 > "" Then
cnstring = "Provider=SQLOLEDB;Password= & zf4;Persist Security Info=True;User ID= & zf3;Initial Catalog= & zf2;Data Source= & zf1"
End If
If Connections.TryConnect(CnString) = True Then
e.ConnectionString = CnString
Else
messagebox.show("无法连接到数据库,请联系管理员.","警告",MessageBoxButtons.OK,MessageBoxIcon.Warning)
Syscmd.Project.Exit()
Return
End If
Else
messagebox.show("没有找到系统配置文件,无法连接到数据,请联系管理员.","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Syscmd.Project.Exit()
Return
End If
但运行后,出现的问题是 “应用程序 发生异常,未知的软件异常 (0*e0434f4d),位置 为 0*7c812fd3”
请协助解决,非常感谢!!