Connect to SQL Server over TCP / IP, not NP
As I found out, my SQL Server disabled Named Pipes, but enabled TCP / IP (and it will stay that way). Now I am trying to connect from visual studio to the database, but no luck. I've tried so far:
string connstring = "Data Source=192.168.1.1:1433 ;Initial Catalog=np-sparcsn4-custom;Persist Security Info=True;User ID=xxxx;Password=/*****/";
string connstring = "Data Source=192.168.1.1:1433 ; Network Library=DBMSSOCN; Initial Catalog=np-sparcsn4-custom;Persist Security Info=True;User ID=xxxx;Password=/*****/";
I tried replacing the IP address with a name - no luck. When I try to connect using the table adapter I can view the data, same thing if I were using ie grid - but in code I just can't open a connection for it: I always have a network related or server error, either
Named Pipes Provider: Could not open a connection to SQL Server [5]
or
provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server
The server is configured to accept remote connections and is available.
Update:
I tried
string connstring = "Server=tcp:192.168.1.1,1433 ;Initial Catalog=np-sparcsn4-custom;Persist Security Info=True;User ID=xxx;Password=/****/";
or
"Server=tcp:ponln4report,1433 ....
and I have an error:
provider: TCP Provider, error: 0 - A non-recoverable error occurred during a database lookup**strong text**
EDI2: I found an older SQL Server 2005 that I can connect to without issue. It's a bit of a pain because it lacks date and time data types, but I think this should be done now.
source to share
For C # use this connection string
connectionString="Data Source=192.168.1.1,1433;Initial Catalog=np-sparcsn4-custom;Integrated Security=false;User ID=your_username;Password=your_password"
If you need to change your web.config file add this node:
<connectionStrings>
<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Data Source=192.168.1.1,1433;Initial Catalog=np-sparcsn4-custom;Integrated Security=false;User ID=your_username;Password=your_password" providerName="System.Data.SqlClient" />
</connectionStrings>
source to share
Make sure port 1433 is set to IPALL in SQL Configuration Manager -> Protocols
for SQLEXPRESS
screenshot
source to share