views:

128

answers:

1

I'm using Microsoft SQL Server Database File (SqlClient), name UHMS.mdf and I'm not able to connect to it. can someone help please.

thanks.

+1  A: 

With SQL Server, you don't connect directly to a file. You connect to a SQL Server instance, which has a set of databases mounted. Each database consists of two (one data, one log) or more data files. The UHMS.mdf data file will be associated with a database. Also, you can connect using either SQL Server Authenticated or Windows Authenticated logins. So what you need to know is:

  1. The name of the SQL Server server and instance to use;
  2. The database name to initially connect to that has the UHMS.mdf data file mounted -- maybe it's named UHMS ?
  3. Which authentication mode to use. If SQL Server Authentication, you'll need the username and password. If Windows, your account will need to be set up by the sysadmin to allow your connection to the SQL Server instance.

See www.connectionstrings.com for examples of connection strings to use.

bretlowery
except for SQL Server Express - there you **can** specify a specific file using a connection string like `Server=.\SQLExpress;AttachDbFilename=c:\asd\qwe\mydbfile.mdf;Database=dbname; Trusted_Connection=Yes;`
marc_s