Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

HTML
<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 :-

VB
 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 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
Posted

1 solution

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
 
Share this answer
 
Comments
Parveen Rathi 22-Sep-11 11:37am    
sir actually I make a window application in vb.net and share the exe file of it on different system having different operating system like xp, vista, and 7 it give only the it not open the connection while the connection string is valid so please tell any other way to check the connection string is accurate or not without open the connection

Thanks in advance
Dylan Morley 22-Sep-11 11:39am    
You need to catch the Exception and do something with the Exception details. Either display them on the screen, or dump them to a log file.

At the minute, you are catching the exception but ignoring what the message is - you are just displaying your own custom 'Incorrect information' message, which doesn't help diagnose the issue.

Catch the exception, log it then post it here.

We need to know WHAT the exception is before we can fix it!!
Parveen Rathi 24-Sep-11 2:35am    
I'm check the server name if it is valid or not so i need to open the connection if it if it not correct then it show the message "Invalid server name" and show other form otherwise my application proceed

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900