Cannot connect to an mdf file

Last post 05-14-2008 7:38 AM by tracer. 14 replies.

Sort Posts:

  • Cannot connect to an mdf file

    05-08-2008, 3:55 PM
    • Loading...
    • skiabox
    • Joined on 11-11-2007, 8:04 AM
    • Posts 8

     I am trying to connect to an mdf file using Data Source Configuration Wizard, I am using as Data source 'Microsoft SQL Server Database File (SqlClient) .

    I get an error saying that sql server might not allow remote connections which is not true (this option is checked).

    Any ideas what is going wrong? 

  • Re: Cannot connect to an mdf file

    05-08-2008, 4:11 PM
    • Loading...
    • geosync
    • Joined on 03-26-2006, 8:44 PM
    • Boston, MA, USA
    • Posts 332

    MDF is a SQL Server database file.  It's not like an Access MDB; you need to connect to it by using a SQL Server connection string...and SQL Server engine running/.

    ~ Timing is Everything! ~
  • Re: Cannot connect to an mdf file

    05-08-2008, 4:37 PM
    • Loading...
    • skiabox
    • Joined on 11-11-2007, 8:04 AM
    • Posts 8

    Sql server is running. 

  • Re: Cannot connect to an mdf file

    05-08-2008, 4:42 PM
    • Loading...
    • geosync
    • Joined on 03-26-2006, 8:44 PM
    • Boston, MA, USA
    • Posts 332

    Do you have a connection string specified in web.config?

    You cannot connect directly to the MDF.  You must use the connection string defined in web.config

    ~ Timing is Everything! ~
  • Re: Cannot connect to an mdf file

    05-08-2008, 4:53 PM
    • Loading...
    • skiabox
    • Joined on 11-11-2007, 8:04 AM
    • Posts 8

    Basically I am reading the deitel book 'Visual C# 2005: How tp program' and he does just that :

    he directly add a connection to an mdf file to the project.

    If you cannot connect to a file then why there is a 'Microsoft Sql Server Databace File' option? 

  • Re: Cannot connect to an mdf file

    05-08-2008, 5:14 PM
    • Loading...
    • skiabox
    • Joined on 11-11-2007, 8:04 AM
    • Posts 8

    Here is the abstract from the book :

    Step 4: Adding a New Database Connection

    You must next choose the connection that will be used to connect to the database (i.e., the actual source of the data). Click New Connection... to open the Add Connection dialog (Fig. 20.25). If the Data Source is not set to Microsoft SQL Server Database File (SqlClient), click Change..., select Microsoft SQL Server Database File and click OK. In the Add Connection dialog, click Browse..., locate the Books.mdf database file on your computer, select it and click Open. You can click Test Connection to verify that the IDE can connect to the database through SQL Server. Click OK to create the connection.

     

  • Re: Cannot connect to an mdf file

    05-10-2008, 2:50 AM
    • Loading...
    • skiabox
    • Joined on 11-11-2007, 8:04 AM
    • Posts 8

     I managed to connect through sql server but the question about the use of the option 'Microsoft SQL Server Database File' remains.

  • Re: Cannot connect to an mdf file

    05-10-2008, 7:29 AM
    • Loading...
    • geosync
    • Joined on 03-26-2006, 8:44 PM
    • Boston, MA, USA
    • Posts 332

    Hi, I'm not sure why you can't connect directly to the MDF. 

    For the record, your previous notes and my subsequent research indicates my comments earlier in this thread were incorrect.  However, my research hasn't uncovered much guidance to remedy your situation.

    Good luck.

    ~ Timing is Everything! ~
  • Re: Cannot connect to an mdf file

    05-10-2008, 8:26 AM
    • Loading...
    • tracer
    • Joined on 02-08-2008, 7:39 AM
    • Cochin , India
    • Posts 38

    hai skiabox,/p>

    have u gone to the SQL surface Area Configuration for Services and Connections. if not this is what u got to do


    Step 1. From the startup menu, take Microsoft server 2005 >>>Configuration tools>>>SQL surface Area Configuration

    Step 2. from the bottom of the page that has opened select "SQL surface Area Configuration for Services and Connections"

    Step 3. under database engine>>remote Connections(Select this)

    Step 4. now click on the option "local and remote connections" underwhich select "both TCP/Ip and name pipes"

    this is essential to enable webserver to access the sql server

    Plz do mark this as answer if it helped u


    tracer

  • Re: Cannot connect to an mdf file

    05-10-2008, 8:27 AM
    • Loading...
    • tracer
    • Joined on 02-08-2008, 7:39 AM
    • Cochin , India
    • Posts 38

    hai skiabox

    have u gone to the SQL surface Area Configuration for Services and Connections. if not this is what u got to do


    Step 1. From the startup menu, take Microsoft server 2005 >>>Configuration tools>>>SQL surface Area Configuration

    Step 2. from the bottom of the page that has opened select "SQL surface Area Configuration for Services and Connections"

    Step 3. under database engine>>remote Connections(Select this)

    Step 4. now click on the option "local and remote connections" underwhich select "both TCP/Ip and name pipes"

    this is essential to enable webserver to access the sql server

    Plz do mark this as answer if it helped u


    tracer

  • Re: Cannot connect to an mdf file

    05-11-2008, 12:11 AM
    • Loading...
    • tracer
    • Joined on 02-08-2008, 7:39 AM
    • Cochin , India
    • Posts 38
    Are u able to access the file now.


    tracer

  • Re: Cannot connect to an mdf file

    05-12-2008, 3:24 AM
    • Loading...
    • skiabox
    • Joined on 11-11-2007, 8:04 AM
    • Posts 8

    Nope.I get the same error for remote connections problem.

    I tried to use my sql server 2005 which is running with the file and I get this message :

    The user instance login flag is not supported on this version of sql server.

     

     Maybe it has to do with the fact that the author uses sql server express.
     

  • Re: Cannot connect to an mdf file

    05-13-2008, 8:10 PM
    • Loading...
    • devcalpoly
    • Joined on 10-08-2007, 10:03 PM
    • Posts 26

    skiabox.. you won't be able to connect to MDF file (Sql Server Data File) using ASP.NET, as geosync mentioned. You need to install Sql Server and then create a database using that MDF file.

    However, in windows programming you can connect directly to MDF file.

     
    Good Luck.

     

  • Re: Cannot connect to an mdf file

    05-14-2008, 2:23 AM
    • Loading...
    • geosync
    • Joined on 03-26-2006, 8:44 PM
    • Boston, MA, USA
    • Posts 332

    aha!  Windows vs. ASP.Net.  I feel better now.   Thanks, devcalpoly; I hated the idea I was giving out bad info.

    ~ Timing is Everything! ~
  • Re: Cannot connect to an mdf file

    05-14-2008, 7:38 AM
    • Loading...
    • tracer
    • Joined on 02-08-2008, 7:39 AM
    • Cochin , India
    • Posts 38
    skiabox........install sql server 2005(u need that for .NET) and then do what i had posted earlier (the 4 steps). Devcapoly is right u got to install sql server 2005 and make a database there.


    tracer

Page 1 of 1 (15 items)