"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
Jimmacle8mo 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
aslanyunuszitOP8mo ago
okay
aslanyunuszit
aslanyunuszitOP8mo ago
No description
Jimmacle
Jimmacle8mo ago
the connection string is the text that you pass in when you create the SqlConnection
aslanyunuszit
aslanyunuszitOP8mo 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
aslanyunuszitOP8mo ago
sory ı texted to wrong chat here is the code
Jimmacle
Jimmacle8mo 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
aslanyunuszitOP8mo ago
there isnt any data in it, but ı tried to change it to the server name to my computer it didnt work
Jimmacle
Jimmacle8mo ago
that's not what it's asking for
aslanyunuszit
aslanyunuszitOP8mo ago
if it is possibile with you ı can join a voice chat
Jimmacle
Jimmacle8mo 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
aslanyunuszitOP8mo ago
No description
aslanyunuszit
aslanyunuszitOP8mo ago
it is this ı suppose
Jimmacle
Jimmacle8mo ago
probably
aslanyunuszit
aslanyunuszitOP8mo ago
yea ı tried it to change it but problem still contunius
Jimmacle
Jimmacle8mo 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
aslanyunuszitOP8mo 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
aslanyunuszitOP8mo ago
now it gives this error
No description
aslanyunuszit
aslanyunuszitOP8mo ago
do place of sql file matter mine is on desktop?
aslanyunuszit
aslanyunuszitOP8mo ago
No description
Jimmacle
Jimmacle8mo 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
aslanyunuszitOP8mo ago
ı click to icon and it enter to sql
aslanyunuszit
aslanyunuszitOP8mo ago
No description
aslanyunuszit
aslanyunuszitOP8mo 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
Jimmacle8mo 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
aslanyunuszitOP8mo ago
now ı see it realy isnt exist ı was trying to acces it through user mapping and gts isnt there
Jimmacle
Jimmacle8mo ago
it won't be there unless you create it
aslanyunuszit
aslanyunuszitOP8mo ago
ım on it
aslanyunuszit
aslanyunuszitOP8mo ago
is gts in right folders?
No description
No description
aslanyunuszit
aslanyunuszitOP8mo ago
ı created it
aslanyunuszit
aslanyunuszitOP8mo ago
well, now this come out..
No description
aslanyunuszit
aslanyunuszitOP8mo ago
it doesnt exist either ı will create it quickly
Jimmacle
Jimmacle8mo 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
aslanyunuszitOP8mo 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
Jimmacle8mo ago
:pepeok:
aslanyunuszit
aslanyunuszitOP8mo ago
🙏🏽 🫡
Want results from more Discord servers?
Add your server