老大,我在退出的按钮中加入底下的代码:
Dim Result As DialogResult
Result = MessageBox.Show("需要保存吗?", "提示", MessageBoxButtons.Yesno, MessageBoxIcon.Question)
If Result = DialogResult.Yes Then
Dim ipFile As String = ProjectPath & "data\ip.txt"
If Filesys.FileExists(ipFile) Then
Dim s As String = FileSys.ReadAllText(ipFile,Encoding.Default)
MessageBox.show(s) '读出连接的字符串
If Connections.TryConnect(s) = False Then
MessageBox.Show("数据源无法连通!")
Return
Else
MessageBox.Show("数据源可以连通!")
End If
End If
End If
在外部的文件 ip.txt中的字符串连接是:
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & ProjectPath & "data\服务器.mdb;Persist Security Info=False
但是利用 MessageBox.Show能顺利读出连接字符串,但是代码判断就不行(不管加不加双引号都不行!),错误如下:

此主题相关图片如下:tm截图未命名.jpg

但是我直接将字符串加入代码中测试就可以顺利判断连通.是什么问题?
[此贴子已经被作者于2011-11-25 8:30:57编辑过]