全局代码中设置了:
'判断是否连接数据库成功
Public isconnected As Boolean
BeforeConnectOuterDataSource事件中写了:这个代码
If e.Name = "ERPdatabase" Then
Dim pathP As String = "System/DatabasePath"
Dim xmlDoc As New System.XML.XmlDocument
xmlDoc.Load(config)
Dim xmlNd As System.XML.XmlNode = xmlDoc.SelectSingleNode(pathP)
Dim databasePath As String = xmlNd.InnerText
MessageBox.show(databasePath)
Dim pathN As String = "System/DatabaseName"
Dim xmlNd1 As System.XML.XmlNode = xmlDoc.SelectSingleNode(pathN)
Dim databaseName As String = xmlNd1.InnerText
MessageBox.show(databaseName )
Dim pathPS As String = "System/DatabasePassword"
Dim xmlNd2 As System.XML.XmlNode = xmlDoc.SelectSingleNode(pathPS)
Dim databasePassword As String = xmlNd2.InnerText
MessageBox.show(databasePassword )
Dim s As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & databasePath & "\" & databaseName & ";Persist Security Info=False;Jet OLEDB:Database Password=" & databasePassword
MessageBox.show(s)
MessageBox.show(Connections.TryConnect(s))
If Connections.TryConnect(s) = False Then
MessageBox.Show("数据源无法连通!")
MessageBox.show(1)
e.HideSplashForm = True
MessageBox.show(2)
isconnected= False
MessageBox.show(3)
Else
MessageBox.show(4)
isconnected= True
MessageBox.show(5)
e.ConnectionString = s
End If
MessageBox.show(e.ConnectionString)
MessageBox.show(Isconnected)
没发布项目的时候,一切正常。发布后在其他计算机上运行的时候,执行到 【isconnected= True】,就莫名其妙的退出了,没有提示错误
(【MessageBox.show(5)】这一步没有执行,【MessageBox.show(4)】这一步执行了)就卡在isconnected上面