"Help Needed: SQL Server Connection Error :("

I am encountering the following error while trying to connect to SQL Server: System.Data.SqlClient.SqlException: '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: 26 - Error Locating Server/Instance Specified)' A few months ago, a friend and I completed a project on his computer. He sent me the project along with the SQL file. Now, when I try to start the project, this error occurs. As a beginner to SQL, I don't think it's a major error to fix, but I tried a couple of solutions and it got more complicated. Can anybody help me?
36 Replies
Jimmacle
Jimmacle2mo ago
SQL Server is an actual program that needs to be running on your computer for your program to connect to can you share the connection string?
aslanyunuszit
aslanyunuszit2mo ago
okay
aslanyunuszit
aslanyunuszit2mo ago
No description
Jimmacle
Jimmacle2mo ago
the connection string is the text that you pass in when you create the SqlConnection
aslanyunuszit
aslanyunuszit2mo ago
its connected with with this code its different on my computer ı tried to change it to my server name but error continued
No description
aslanyunuszit
aslanyunuszit2mo ago
sory ı texted to wrong chat here is the code
Jimmacle
Jimmacle2mo ago
so you need an instance of SQL Express installed and you need to change the connection string to the instance name, username, and password that you set when you set it up and probably import the data that your friend sent you into the gts database
aslanyunuszit
aslanyunuszit2mo ago
there isnt any data in it, but ı tried to change it to the server name to my computer it didnt work
Jimmacle
Jimmacle2mo ago
that's not what it's asking for
aslanyunuszit
aslanyunuszit2mo ago
if it is possibile with you ı can join a voice chat
Jimmacle
Jimmacle2mo ago
i can't do voice chat the data source should be localhost\\YOURINSTANCENAME instance name being the name of the sql server instance, not your computer name
aslanyunuszit
aslanyunuszit2mo ago
No description
aslanyunuszit
aslanyunuszit2mo ago
it is this ı suppose
Jimmacle
Jimmacle2mo ago
probably
aslanyunuszit
aslanyunuszit2mo ago
yea ı tried it to change it but problem still contunius
Jimmacle
Jimmacle2mo ago
the equivalent connection string for that would be @"Data Source=localhost\SQLEXPRESS;Initial Catalog=gts;Integrated Security=true" integrated security means it will use your windows credentials to authenticate instead of username/password
aslanyunuszit
aslanyunuszit2mo ago
oh okayy let me try it real quick yea it didn't work probably ı am making little mistakes here and there pretty new to coding but ı got this point thank you for your time
aslanyunuszit
aslanyunuszit2mo ago
now it gives this error
No description
aslanyunuszit
aslanyunuszit2mo ago
do place of sql file matter mine is on desktop?
aslanyunuszit
aslanyunuszit2mo ago
No description
Jimmacle
Jimmacle2mo ago
the sql file has nothing to do with your database, ignore it for now the error is now because your login is incorrect, but on the bright side it's connecting to the server so it's better than the last error how do you normally get into your sql server? actually that one might be because the DB doesn't exist or your user doesn't have access to it
aslanyunuszit
aslanyunuszit2mo ago
ı click to icon and it enter to sql
aslanyunuszit
aslanyunuszit2mo ago
No description
aslanyunuszit
aslanyunuszit2mo ago
ı clic to conect here and this opens ı usualy use the local databse on visual studio ım little bit familiar with sql server but this is the first time ı really interact with it
Jimmacle
Jimmacle2mo ago
then the problem is most likely that the gts database doesn't exist you'll need to create it and then i'm guessing the sql file you have is a script to create all the tables the program needs
aslanyunuszit
aslanyunuszit2mo ago
now ı see it realy isnt exist ı was trying to acces it through user mapping and gts isnt there
Jimmacle
Jimmacle2mo ago
it won't be there unless you create it
aslanyunuszit
aslanyunuszit2mo ago
ım on it
aslanyunuszit
aslanyunuszit2mo ago
is gts in right folders?
No description
No description
aslanyunuszit
aslanyunuszit2mo ago
ı created it
aslanyunuszit
aslanyunuszit2mo ago
well, now this come out..
No description
aslanyunuszit
aslanyunuszit2mo ago
it doesnt exist either ı will create it quickly
Jimmacle
Jimmacle2mo ago
the sql file is not a database it's a script that you have to run on the gts database to create the tables
aslanyunuszit
aslanyunuszit2mo ago
It workedd!!!! Finally, I truly thank you for your patience If you weren't here, I would probably be working on this for a couple more hours.
Jimmacle
Jimmacle2mo ago
:pepeok:
aslanyunuszit
aslanyunuszit2mo ago
🙏🏽 🫡