As I found out, my SQL server has disabled Named Pipes, but enabled TCP/IP (and it will stay this way). Now I am trying to connect from the visual studio to the database, but with 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've tried to replace the IP address with name - no luck. When I try to connect using the table adapter I can preview the data, same if I'd use i.e. grid - but in the code I simply can't open connection to it: I always have Network related or server specific error, usually its 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
Server is set up to accept remote connection and it is accessible.
Update:
I've 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've got error:
provider: TCP Provider, error: 0 - A non-recoverable error occurred during a database lookup**strong text**
EDI2: I've found an older SQL server 2005 that I can connect without a problem. It is a bit of a pain because it lacks i.e. Date and Time data types, but I guess it has to do for now.
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 modify a 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>
Make sure port 1433 is set in IPALL in the SQL Configuration Manager -> Protocols for SQLEXPRESS
screenshot
Related
I installed a windows form application on a client computer but when I try to log into my application it gives me this error:
a connection was successfully established with the server, but then an error occurred during the login process. (provider: shared memory provider, error: 0- No process is on the other end of the pipe.)
This is a c# windows form application running with SQL Server database, with login details. I have added the in and out bound rule on my firewall, I have tried changing my connection string severally, I have enabled tcp/ip port with its default port number, I have tried using the same network for both computers, I have tried using window and sql authentication, I have disabled firewall on client computer
Here is my connection string
<add name="connstrng" connectionString="Data Source=(local);Initial Catalog=AnyStore;Integrated Security=True"/>
I expect to be logged in to my application on the client computer using the same database with my server computer.
Connection strings are usually defined within the Web.config file. As #Panagiotis Kanavos said, the string is connecting to a local data source, which should work as expected within your dev environment. The web.config file should be located within the root directory of your project. Edit this file on the client's machine to point to the expected server / database. You may want to keep a blank or default version of this file in source control to avoid overwriting other's connection string info.
Example String:
<add name="SomeDB" connectionString="Data Source=snapdragon\SQL2k14;database=DBNAME;User Id=username; password=password" providerName="System.Data.SqlClient" />
Edit: "snapdragon" would be the host computer name. "SQL2k14" would be your sql server instance.
ok, i found the solution i changed my connection string and its working fine now, thanks guys.
here is my connection string-
<connectionStrings>
<add name="connstrng" connectionString="Data Source=DESKTOP-5I8TFY3\EMEKA;Initial Catalog=AnyStore;User ID=adminpos;Password=********" />
</connectionStrings>
</configuration>
I've seen this error answered for other people, but I can't seem to get it to work. I'm trying to connect to a SQL Server Database project locally.
I'm getting this error thrown on Open() when I do the follow:
SqlConnection conn = null;
conn = new SqlConnection(connection)
conn.Open()
Where connection is a connection string passed from my webconfig. I've found examples online and tried these three connection strings and I get the same error every time:
<add name="TICKETING_CONNECTION" connectionString="Server=(local); DataBase=Ticketing_DB; Integrated Security=SSPI"/>
<add name="CONN"
connectionString="Data Source=localhost; Integrated Security=SSPI;Initial Catalog=Ticketing_DB"
providerName="System.Data.SqlClient" />
<add name="CONN2"
connectionString="Data Source=(local);Initial Catalog=Ticketing_DB;"
providerName="System.Data.SqlClient"
/>
Could the problem be stemming from the path of where the database is located on my machine? I've tried copying the c:\ path but didn't have any luck. I've seen some examples online use a .mdf file, but my project does not have this file either.
This is my first time trying to connect to a database project, so any help or advice would be greatly appreciated
If you are using Visual Studio try going to the Server Explorer and Right click on Data Connections and Add new connection by selecting DataSource as Microsoft SQL Server and provider as .net framework provider for SQL Server.
Under the server name check for the SQL Server if it is listed with your machine name.
Then try to provide the database details and user name and password for SQL Authentication or select windows for windows authentication. Then do a test connection. If it is fine on click of OK it will add the data connection.
Right click the properties of data connection which is newly added and navigate to properties to extract the connection string. Compare it with yours. This can help you troubleshoot the issue.
ich got some problems connecting to the database stored on a server in the local network. I tryed almost everything, but nothing helps.
I got 2 Databases, MYSQL and MSSQL.
Configuration:
Server: 192.168.0.198
MYSQL Port: 3306
MSSQL Port: 1433
If i connect manuelly in Visual Studio it works, but if i copy the ConnectionString from the properties, it only connects to the MYSQL Database and not the MSSQL (same login, same password, same ip adress, but ports are different)
In Visual Studio is P3B-Server\P3BMSSQL for the server and db_Software for the database
Visual Studio Properties:
"Data Source=P3B-Server;Initial Catalog=db_Software;User ID=myUser;Password=mypassword"
But it doesnt work :/
I tryed
"Data Source=P3B-Server..."
#"Data Source=P3B-Server\P3BMSSQL..."
"Data Source=192.168.0.198,1433..."
"Data Source=tcp:192.168.0.198,1433..."
Still no connection to MSSQL Server, only MYSQL Server.
I`m connecting with HeidiSQL to both Databases and got
"Microsoft SQL Server (TCP/IP, experimental)" with 192.168.0.198, Port 1433,
user=myUser and Password=mypassword" for the MSSQL Server and there it works.
Checked "connectionstrings.com", but no solution works for me.
PS: Other side is an ASP.NET application, which connects with
<connectionStrings>
<add name="ApplicationServices" connectionString="Data Source=192.168.0.198;Initial Catalog=db_Software;User Id=myUser;Password=myPassword;" providerName="System.Data.SqlClient"/>
</connectionStrings>
(stored in Web.config) to the database.
I need exact this for my C# application as a Connectionstring.
Please help me. Thanks !
<connectionStrings>
<add name="ApplicationServices" connectionString="Data Source=192.168.0.198\P3BMSSQL;Initial Catalog=db_Software;User Id=myUser;Password=myPassword;" providerName="System.Data.SqlClient"/>
</connectionStrings>
I'm currently trying to connect from Visual Studio 2013 C# application to a SQL Server 2012 instance but I'm running into troubles. Namely error 26 that no connection could be created.
My question there is what could still be wrong with what I'm doing (I'll post the code snippets I use below and then also what I controlled so far / steps I took):
Code
I created an application config which has the following line:
<connectionStrings>
<add name="DefaultConnectionString"
connectionString="Data Source=TH-HP\SQLEXPRESS;Initial Catalog=BB;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False"
providerName="System.Data.SqlClient"/>
</connectionStrings>
I use an intermediary class I call Database to create the connection strings and run the commands.
When initializing it I use the following command (which sets the private variable connectionStr):
Database db = new Database(Properties.Settings.Default.ConnectionString);
Then when I try to open the connection:
SqlConnection con = new SqlConnection(this.connectionStr);
con.Open();
The error happens.
Steps
(as note both the program and the SQL Server instance are running on the same machine)
Correct servername
Correct catalogue name
SQL Server accepts remote connections
Server Browser is running
Server itself is running (connected to it via management console)
Like I said I'm running out of ideas what to check next.
this link may help: How to connect to local instance of SQL Server 2008 Express
also make a try with changing ConnectionString to:
<add name="DefaultConnectionString" connectionString="Data Source=TH-HP;Initial Catalog=BB;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False" providerName="System.Data.SqlClient"/>
or
<add name="DefaultConnectionString" connectionString="Data Source=.\SQLEXPRESS;Initial Catalog=BB;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False" providerName="System.Data.SqlClient"/>
Hello everybody i have a question and confusion about a project that i developed, and I will be very happy if you help me to improve my project.
I worked in VS2010 with C# and my database is attached in Sql Server 2008. my app is supposed to work in a LAN, so i'm thinking to make two versions of this app, the first will include the database and the sql server(plus the winforms of course), the second will just contain dotNet framework and it's supposed to connect to the database installed on the other machine. Is it possible. If so, how??
yes it is posible.
alter your connection string's "data source" to "ip address of the server"
Suppose in your machine where sql server is installed you are using this connection string
"data source=localhost;initial catalog=databasename;uid=sa;pwd=password"
then in the client system you need to alter it like this
"data source=IpAddressOfTheServer;initial catalog=databasename;uid=sa;pwd=password"
Note: the application having server's ip address in connection string is accessible by both, server and the client.
if Connection String in your (c# ) code Setted, Change connection string's "Data Source" to "IP address of server"
an another way change connection string in (App Config or WebConfig) at StartUp Project by below format:
<configuration>
<connectionStrings>
<add name="DB" connectionString="Data Source=192.168.10.5;
Initial Catalog=SafetyDB;Persist Security Info=True;User ID=sa;
Password=a1234$; connection timeout=5000" />
</connectionStrings>