在Windows Vista中无法打开连接 [英] Not open connection in window vista
问题描述
嗨..朋友,我在vb.net中开发了一个窗口应用程序,在其中保存并保存了&从名为emp.xml的xml文件中检索数据,该文件看起来像
Hi.. friends I have developed a window application in vb.net in which I save & retrieve data from xml file named emp.xml which looks like as
<newdataset>
<newdataset>
<pid>0</pid>
<servername />
<serverpwd />
</newdataset>
<newdataset>
<pid>1</pid>
<servername>192.168.2.157</servername>
<serverpwd>sa1</serverpwd>
</newdataset>
</newdataset>
我在表单加载中编写以下代码,并检查它是否有效连接:表单加载的代码是否为:-
I write the following code on the form load and check is it valid connection or not the code of form load is :-
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim dt As New DataSet()
dt.ReadXml(Directory.GetCurrentDirectory().ToString() & "/emp.xml")
Dim tagValue As String = "1"
Dim dr As DataRow() = dt.Tables(0).[Select]("PID=" & tagValue)
If dr.Length <> 0 Then
ServerName = dr(0)("ServerName").ToString()
ServerPwd = dr(0)("ServerPwd").ToString()
Try
Dim ConCheck As New SqlConnection("Data Source=" & ServerName & "\SQLEXPRESS;Initial Catalog=DUKE_Rathi;User ID=sa;Password=" & ServerPwd)
ConCheck.Open()'not open connection in window vista, throw exception
ConCheck.Close()
Catch ex As Exception
'display this message only in window vista again and again working well in xp and 7
MsgBox("Incorrect information, Please Enter again")
End Try
Else
MsgBox("Please Enter your Server information")
End If
End Sub
ServerName和ServerPwd是字符串类型的全局变量,我的项目运行良好,可以在Windows XP和Windows 7上成功保存和检索,但是当我在Windows Vista上共享它时,它无法打开连接抛出异常并一次又一次地发出消息,我在异常中给出阻止信息不正确,请再次输入",我将exe共享给所有计算机,请帮帮我
ServerName and ServerPwd is global variable of string type, My project working well save and retrieve successfully on window xp and window 7 but when I share it on window vista it cannot open the connection throw exception and give message again and again which I give in exception block "Incorrect information, Please Enter again", I shared the exe to all the computers, please help me
推荐答案
确定,那么抛出什么异常?
您可以通过在您的Catch块中添加如下内容来解决此问题:
OK, so what''s the Exception being thrown?
You can work this out in your Catch block by putting something like...
MsgBox(ex.Message)
找出抛出的异常是什么您已经解决了一半问题……很可能与权限相关,但是您需要为我们提供更多信息,以帮助您进一步
Find out what the exception is that''s being thrown & you''re half way to solving the problem...it''s likely to be permission related, but you need to provide the extra information for us to help you further
这篇关于在Windows Vista中无法打开连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!