"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
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?
okay
the connection string is the text that you pass in when you create the SqlConnection
its connected with with this code its different on my computer ı tried to change it to my server name but error continued
sory ı texted to wrong chat here is the code
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
databasethere isnt any data in it, but ı tried to change it to the server name to my computer it didnt work
that's not what it's asking for
if it is possibile with you ı can join a voice chat
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 nameit is this ı suppose
probably
yea ı tried it to change it but problem still contunius
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/passwordoh 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
now it gives this error
do place of sql file matter mine is on desktop?
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
ı click to icon and it enter to sql
ı 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
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 needsnow ı see
it realy isnt exist ı was trying to acces it through user mapping and gts isnt there
it won't be there unless you create it
ım on it
is gts in right folders?
ı created it
well, now this come out..
it doesnt exist either ı will create it quickly
the sql file is not a database
it's a script that you have to run on the gts database to create the tables
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.
:pepeok:
🙏🏽 🫡