Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have created a vb.net code to list a data from table

code is given below


VB
Imports System.Data.SqlClient
Public Class Form1
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim connetionString As String
        Dim connection As SqlConnection
        Dim command As New SqlCommand
        Dim ds As New DataSet
        Dim sno As Integer

        connetionString = "Data Source= SIDHARTH-PC ;Initial Catalog= Agreement ;User ID=sa;Password= XXXXX"
        connection = New SqlConnection(connetionString)
        connection.Open()
        command.Connection = connection
        command.CommandType = CommandType.StoredProcedure
        command.CommandText = "ShowAgrementtext"
        sno = 1
        command.Parameters.AddWithValue("@sno", sno)
        Dim reader As SqlDataReader = command.ExecuteReader()
        If reader.Read() Then
            MsgBox(Convert.ToString(reader(0)))
        Else

        End If
        connection.Close()

    End Sub
End Class



i came to know that a file inside bin folder creates an exe file... it works fine in my systems.
when i execute the same file in another system. it show connection error (with database). but
systems are connected via network.


Thanking you in advance.
Posted
Comments
Kornfeld Eliyahu Peter 21-May-14 5:18am    
What the error is?
Sidharth R 21-May-14 5:36am    
Unhandled Exception has occurred in your application.

A network related or instance-specified error occurred while establishing a connection to sql server. The server was not found or was not accessible verify that instance name is correct and sql server is configured to allow remote connection (provider: named pipes provider , error 40 - could not open a connection to sql server )
Kornfeld Eliyahu Peter 21-May-14 5:39am    
"The server was not found or was not accessible"...
SIDHARTH-PC is not accessible from the other computer - check your network declarations like firewall...
Sidharth R 21-May-14 5:41am    
network firewall is off inside local network..
but i can access other SQL servers from my local machine.
Kornfeld Eliyahu Peter 21-May-14 5:42am    
What edition the SQL server on SIDHARTH-PC?

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