I am using VS2010 and created a database using SQL server residing in VS2010. the database is stored in the folder APP_DATA with an extension .mdf

My PC name is rvivek and it resides in a domain. below is my connection string.

myConnection = New SqlConnection("server=rvivek; uid=; pwd=; database=Database1.mdf;")

when i run my program i am getting the below error.

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible.

Kindly advice how to specify the server name. and also i've not given any username and password for the database. kindly help me.

5 Years
Discussion Span
Last Post by MikeSmithDev

using SQL server

Since you are using SQL Server you need to provide a user id and password too. The database name should be Database1 if that is the name. You are trying to open it like an Access file, that is not possible. Server name could also be localhost in your case, or your IP address.

myConnection = New SqlConnection("server=localhost; uid=; pwd=; database=Database1.mdf;")
myCommand = New SqlCommand(strSQL, myConnection)
MsgBox("Connection Open")

this is my code. My database is available in the APP_DATA folder. even now same problem exists.

Kindly help


myConnection = New SqlConnection("server=localhost; uid=rvivek; pwd=; database=Database1;")

What user id should i give ..


i,ve forgotten the user name what i've given at the time of installing. Is there any way to find out.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.