connectionString - web.config - dbf

Discussion in 'ASP.NET 2.0' started by SpartanWolf, Jul 22, 2006.

  1. Background: VERY new to ASP. Have created site and everything works fine locally.

    I purchased a MS SQL 2005 server package and the database is named: SQL2005_266736_spartanburg
    I was able to upload my datafile (Spartanburg.mdf) and successfully attached the mdf to the SQL 2005 database using the Database Manager - SQL Tools (Beta).

    In the connection string section of my web.config file, I currently have:

    <remove name='LocalSqlServer' />
    <add name='ConnectionString' connectionString='
    Data Source=sql2k502.discountasp.net;
    Initial Catalog=SQL2005_266736_spartanburg;
    Database=Spartanburg.mdf;
    User ID=kerryw60sc;
    Password=myPassword;
    Trusted_Connection=False' providerName='System.Data.SqlClient' />

    I'm now receiving the following error:
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    Cannot open database 'Spartanburg.mdf' requested by the login. The login failed.
    Login failed for user 'kerryw60sc'.
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

    I have double-checked the username and password. I suspect I have something wrong in my code in trying to access the Spartanburg.mdf on the SQL2005_266736_spartanburg.

    Will greatly appreciate any help!!

    Thanks!
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    Get rid of this line from your connection string

    Database=Spartanburg.mdf;

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  3. Thanks for helping!!

    That seems to work!!

    SO, as long as you just connect to your server and you have previously attached your mdf file, it will find it??

    Can multiple mdf files be attached? For example: I have attached the mdf with my data, could I also attach the standard ASPNETDB.MDF to utilize the membership features or would I have to purchase another SQL Server from DiscountASP.net for that?

    THANKS!!
     
  4. Bruce

    Bruce DiscountASP.NET Staff

    basically, when you run the attach tool, the system copies your SQL Express database file to the SQL 2k5 server hosting your database and run a series of commands to attach (or convert) your Express database file to the SQL 2k5 server.


    You cannot attach more than 1 database without overwriting each other's database.


    If you are using ASPNETDB, there are 2 ways to go about this


    1) you should consider using the ASPNET_REGSQL tool to generate the schema. ie. Attach the database with application data, then run the aspnet_regsql tool to create the aspnetDB schema


    or


    2) install the aspnetDB schema to your application database and attach the whole thing.


    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  5. Thank you VERY much for your assistance.

    The information you provided was very helpful.

    THANKS!!
    Kerry
     

Share This Page