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.
it is showing error, stored procedure not found.
My app config's connection string is as below.
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.
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.GreenDim 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
Any help is highly appreciated. Thanks in advance,.
-
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.
it is showing error, stored procedure not found.
My app config's connection string is as below.
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.
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.GreenDim 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
Any help is highly appreciated. Thanks in advance,.
You are connecting to two different databases. One is a full SQL Server database; the other is a "LocalDB" database. SQL Server Express LocalDB - SQL Server | Microsoft Docs[^] LocalDB databases cannot be accessed across the network.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
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.
it is showing error, stored procedure not found.
My app config's connection string is as below.
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.
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.GreenDim 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
Any help is highly appreciated. Thanks in advance,.
Thanks for posting the username and password in your connection string. You might want to change that account name and password now and don't ever use that account name ever again.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
Dave Kreskowiak -
Thanks for posting the username and password in your connection string. You might want to change that account name and password now and don't ever use that account name ever again.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
Dave KreskowiakIt's not even a private IP address! :laugh: Looks like the OP is using Verizon as their ISP. I wonder whether they've managed to open port 1433 up to the internet? :evilgrin:
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
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.
it is showing error, stored procedure not found.
My app config's connection string is as below.
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.
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.GreenDim 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
Any help is highly appreciated. Thanks in advance,.
I'm really sorry not being able to give you a good solution for this problem you are describing. However, I recommend you going to the tech forum on Craiglist. You could find an answer over there.