sql server, database stored procedure not working with ip address, please help.
Dear folks.
I am writing a program for connecting sql server database, and populating data from table using a stored procedure. it is working fine when I use the app.config file's data source as the server name, but when I use the server's ip address and port, it is not working.
But when I use Data Source by name as Data Source=(localdb)\SubdivprojV13; it is working all good. The problem is with ip address and port. I checked the connection, connection is opening. But showing error as stored procedure not found.
please check my code snippet.
Code:
Public Class Form1
Dim connection As New SqlConnection(ConfigurationManager.ConnectionStrings("CONNECTION_FLOR").ConnectionString)
Private Sub BTN_DISPLAY_Click(sender As Object, e As EventArgs) Handles BTN_DISPLAY.Click
Dim cmd As New SqlCommand With {
.Connection = connection,
.CommandType = CommandType.StoredProcedure,
.CommandText = "SP_DISPLAY"
}
cmd.Connection.Open()
lbl_CONN.Text = "Connected"
lbl_CONN.ForeColor = Color.Green
Dim dt As DataTable = New DataTable()
dt.Load(cmd.ExecuteReader)
DataGridView1.DataSource = dt
DataGridView1.Update()
If connection.State = ConnectionState.Open Then
connection.Close()
lbl_CONN.Text = "DisConnected"
lbl_CONN.ForeColor = Color.Red
End If
End Sub
End Class
The error I am getting is in attachment, you can see connection is connected, but the stored procedure is not found.
Any help is highly appreciated. Thanks in advance,.
Last edited by VictorN; April 12th, 2021 at 11:52 AM.
Reason: adding CODE tags
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.