how to connect to sql server?
i want to connect to microsft sql server and i get error the the database doesnt exist and it is
33 Replies
what's your connection string ?
string connectToServer = "Data Source=.;Integrated Security=True;Encrypt = False";
🤔
ideas?
this sql query should give you the connection string
do this in ssms
what is ssms?
.
what do you use as database explorer ?
visual studio ?
msms
🤔
mssms
Microsft sql server managment studio
i'm pretty sure you mean ssms xD
but i doing it in c#
visual studio
you need the correct connection string to connect to your database
datasource should not be a dot
the dot is localost
🤔
you don't have catalog in the connection string here
string connectToServer = string.Format("Data Source=.;initial catalog={0};Integrated Security=True;Encrypt = False",database);
con = new SqlConnection(connectToServer);
.
i've always use that kind of connection string 🤔
Server=<URL>;Database=<NAME>;User ID=<USERNAME>;Password=<PASSWORD>
( by connecting using sql connection not windows )i think its login issue but i am not setting any password or username'
i think the default configuration use windows configuration
i am using it
.
yeah that's what i meant
idk how it works with that
oh thx anyway
Maybe you have multiple instances of SQL Server and . is pointing to a wrong one. Try connect to server on SSMS with . as server name and check if the database exists there.
ok
But its localhost so it points to the server that runs doesnt it?
localhost points to the current device.
You can have multiple SQL Server versions on a single device, default instance which is an unnamed instance, and named instances. There can only be one default instance, while you can have multiple named instances. The default instance is set by the installer and I personally do not know how to change it.
So if you do
localhost
you will get the default instance, if you want to get a named instance you would have to do localhost/InstanceName
Ok