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>
Related
I can't connect to my local SQL Server Express instance via Entity Framework. When I try to run the update-database command, I get this error message.
Login failed for user ''. Reason: An attempt to login using SQL authentication failed.
Server is configured for Integrated authentication only.
Error: 18456, Severity: 14, State: 58.
From what I understand, Visual Studio is attempting to log in to SQL Server via a user account even though I've requested that Windows authentication is used in the connection string.
I can still access the server via SSMS.
What I've tried. None of which helped
Different variations of the connection string
Opened port 1433
Created a test UDL file to test the connection.
A clean reinstall of SQL Server Express (not sure I managed to clean up all the files)
Checked the SQL Server browser is running
Checked server instance is running
Enabled TCP/IP & named pipes
Tried connecting via tcp which works
Added Integrated Security=SSPI to connection string
Changed server to accept Windows authentication and SQL Server authentication.
Restarting PC
This is a new laptop on windows 11, I don't know if that is causing any issues as I've never had an issue with this process on Windows 10.
I seem to have two instances; .\SQLEXPRESS & (localdb)\\MSSQLLocalDB I'm not sure if this is causing some conflict or if this is the intended behaviour.
Here is the connection string, I pulled this from the server explorer within Visual Studio so I am pretty sure this is correct. On top of that, I have tried numerous variations of this to attempt to fix the issue
"DefaultConnection": "Data Source=LAPTOP-51LB4QTQ\\SQLEXPRESS;Initial Catalog=MicroBlog;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"
This is where I get the connection string in my Program.cs file
builder.Services.AddDbContext<BlogContext>(opt => opt.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection")));
var app = builder.Build();
At this point I'm completely lost, I've read a lot of articles but have not come across any fixes. I'm not a dba just a programmer so have limited knowledge of this side of SQL Server.
You may try like below:
In Web.config file:
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=SUBRATATALUKDER;Initial Catalog=MyDB;Integrated Security=True;" providerName="System.Data.SqlClient"/>
</connectionStrings>
In appsettings.json file:
"ConnectionStrings": {
"DefaultConnection": "Server=SUBRATATALUKDER;Database=MyDB;Trusted_Connection=True;TrustServerCertificate=True;",
}
Note:
Server Name = SUBRATATALUKDER
Database Name = MyDB
100% tested.
I bought a Windows hosting from GoDaddy. I have configured the configuration settings(Adding database and publishing project's files to host)
I can access the database while running the project on the local server.
But when I transfer the project to the server, the project on the server can't do it.
I wrote my connection string to web.config file, here it is:
<add name="xyz" connectionString="Data Source=IP ADDRESS;Initial Catalog=DBNAME;User ID=USERNAME;Password=PASS;Integrated Security=False" providerName="System.Data.SqlClient" />
I used MVC and Entity Framework, I also used layered structure
Thank You.
try to check more details about the connection string that should be used with your database provider. Here you can find several examples about how to create your connection string properly in SQL SERVER.
please notice that if you are working in your host machine, you have not to specify the IP ADDRES of your SQL SERVER but the SERVER NAME just like:
Data Source=(SERVER_NAME) \ DB_INSTANCE_NAME
I hope that it's gonna be useful.
I've got a problem to connect my website with database. The problem is, if I am trying install my website in IIS on the same machine where database is located, I am receiving error: "Login failed for user". But when I am installing my website on a different machine, connection with database works fine. My connection string looks like this:
<add name="DBConnection"
connectionString="Data Source=myServer; Intial Catalog=myDataBase; User Id=myUserId; Password=myPassword"
providerName="System.Data.SqlClient`" />
I have to install webservice on the same location where database is with the same password and login. How correct connection string should look like?
I have used IIS before, but I've never used a database and I've never done a web app. I did the same steps for putting a site onto IIS and everything works EXCEPT for when I go to a page that has a DB connection on it. I've tried a lot and this is all I get.
A network-related or instance-specific error occurred while establishing a >connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.
Windows Application Event Log:
Cannot get a local application data path. Most probably a user profile is not loaded. If LocalDB is executed under IIS, make sure that profile loading is enabled for the current user.
This was built in Visual Studio and I have a SQL Express DB.
I posted my connection strings, any help is greatly appreciated.
I have added this to my applicationHost.config:
<add name="DefaultAppPool">
<processModel identityType="ApplicationPoolIdentity" loadUserProfile="true" setProfileEnvironment="true" />
And now I get:
An attempt to attach an auto-named database for file |MY DB1 FILE| failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\DB1.mdf;Initial Catalog=aspnet-ICCAA_VIZIER-20150223043129;Integrated Security=True" providerName="System.Data.SqlClient"/>
<add name="ConnectionString" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\DB2.mdf;Integrated Security=True;Connect Timeout=30" providerName="System.Data.SqlClient"/>
I was able to figure it out. I changed all my data connections to .\SqlExpress. Which led me to another error of:
Login failed for user ‘NT AUTHORITYNETWORK SERVICE‘
To fix this I followed this guys article to figure it out.
Login Failed For user NetworkService
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>