ConnectionString to my database instead of aspnetdb

  • Have an application that I inherited. Could not get connected to the database so after much searching and reading on internet ran the script aspnet_regsql on the SQL Server. The instructions implied that the script created it's own db and it did. Ran through the options to configure it to accept my roles and the database now allows my screens to come up with appropriate tabs. But I noticed another post that said that you loaded the aspnet_regsql script into your database instead of it creating the aspnetdb database. Now I can get to the aspnetdb but apparently I'm still not getting to my database, because calls to the database are giving me invalid object errors when I try to run Procedures in my database. How do I use the aspnetdb to authenticate and my database for the data? Do I need 2 connection strings? I have added the applicationname into the aspnetdb but how do I associate my applicationname to my database?

  • It can be a complicated are of asp.net

    Yes you will need a different connection string to your app db and aspnetdb.

    Do you have SQL Express, or an SQL Server edition installed?

  • I have SQL Server 2005. The app was designed to Windows Authenticate in Visual Studio 2005 on a server at another location on a different database but with the same schema. I've had to configure it to work at our location with only minor changes referencing our server and database. But they were authenticating to their copy of the database on SQL Server 2000 or SQL Server Express (I'm not sure which) and I'm having to authenticate to another DB Server in SQL Server 2005. Could not get it to work - got my primary Default.aspx up displaying my login name and header (with no errors anywhere) but the "buttons or tabs" would not show up. I was told that was because of permissions. So I created the same groups within Active Directory to authenticate and put my account in the groups. Still nothing. Then I found the articles on aspnet_regsql and installed it and added my groups to the tables. Now I get the buttons but get system.data.sqlclient.exception invalid objects when trying to execute the procedures against my database. The ASP.net database aspnetdb is a separate database. How do I authenticate as with the aspnetdb stuff and still retrieve my data? Do I transfer the aspnetdb to my database? But the instructions clearly stated into a new database. Need help with this.

  • If you look in Machine.config you will find its roleManager provider is most probably pointing to SQLExpress - which means it will look for an ASBNET.mdf in the App_Data directory.

    Override these settings in one of 3 ways

    1) change machine.config (this will change all subsequent projects on your machine, also can be difficult to deploy as some web hosts wont allow you access)

    2) override the settings in web.config

    create a LocalSqlServer connection string in your web.config to use in place of the one in machine.config

    3) create new profile/role/membership provider settings in to look at a new connection string that you create (not named LocalSqlServer)

    And to get your aspnetdb into SQL Server

    1) find the file aspnet.mdf (& log) - copy it to your MSSQL\Data directory of the SQL Server

    2) in SSMS attach the aspnet.mdf database file to your sql server. you'll then need to set up logins and database users to it, (sp_change_Users_Login is useful) . I'm not sure of this step as its a while since I've done it, and I dont; have an aspnet.mdf available to check - I remember having problems but a bit of tweaking with settings/names/permissions seemed to work in the end.

    Make sure you can connect to both databases (separate connection strings)

  • I already have the aspnetdb in my SQL Server 2005 database - that is how I was finally able to get the screens to put the tabs for accessing the database on the screen.

    I will try to make sure that the machine.config is not getting in my way. As soon as I can get the connection strings that I'm using posted I will to show the syntax that I'm using.

    Have both the aspnetdb and the MyDatabase connections strings in my web.config file, but I may have the logic wrong.

    Will post connectionstring and membership providers as soon as I can. Would appreciate any recommendations.

    Thanks for the quick responses.

  • by logic in the message above I meant syntax: Here are my connectionstrings and provider information. What am I doing wrong? any recommendations appreciated.

  • Your stuff may have posted incorrectly because the message board does stuff with html tags (I always leave a space like that to get it to show). So I'm not sure what Tag the parts beginning with type are under, assuming its < add then The fault is probably connectionStringName='LocalSqlServer' if you don't have this defined in the section of your web.config, then it will pick up from either web.config in Windows\Microsoft.Net\Framework\vxx.xx.xx\Configs Or from machine.config - which probably isnt what you want. You will also need name=AspNetWindowsTokenRoleProvider

    to link up the default provider to the specific one.

    Here's an example from an app I did a while ago (attachment) (I hope I've changed all the passwords).

    Points to note: The providers use the TADBUsers database (my equivalent of aspnetdb) the link is in connectionStringName attribute of each to the name attribute of the connection string in . The defaultProvider is a name that links to the name attribute.

  • Thanks for the info and the .txt file - will review and see if it solves my problem. Appreciate your answers.

    Will get back with status. How did you upload the txt file with the "Insert Image" link above?

  • If you're in the Post Reply form

    scroll down to the Post Options box, and click "Edit Attachments"

  • In reviewing the .txt file you posted... I see where the app would connect to the database TADBUsers through the TADBMembershipProvider, TADBRoleProvider and TADBProfileProvider but I don't see how it interfaces with the TADB_Book or TADB_NoPool connectionstrings. It looks like the ASPNETUser has access to both the TADBUsers and TADB databases. So is the "real" database the TADB database and it is connected through the login UID=TADB?

    How does the app know to get data from the TADB database and the authentication from the TADBUsers database?

  • Praise the Lord, the application is up and running....

    From all the advise that I found - all the little pieces...I still don't know the definitive fix.

    But I changed the server machine.config file to not point to SQLEXPRESS and not to a .mdf file instead of the aspnetdb file I had created in SQL Server 2005.

    I also changed the provider application in machine.config to point to the application name that I had referenced in aspnetdb database. (My application is the only application running on this server.)

    Also there were 4 missing functions in the application database that did not transfer when I transfered the app database into SQL Server 2005. And of course those missing functions were the ones that I was using to test whether the app was working or not.

    Thanks for all the comments and recommendations. There are too many little pieces to getting an app such as this up and running.

  • bkwdsarkie (6/25/2009)


    In reviewing the .txt file you posted... I see where the app would connect to the database TADBUsers through the TADBMembershipProvider, TADBRoleProvider and TADBProfileProvider but I don't see how it interfaces with the TADB_Book or TADB_NoPool connectionstrings. It looks like the ASPNETUser has access to both the TADBUsers and TADB databases. So is the "real" database the TADB database and it is connected through the login UID=TADB?

    How does the app know to get data from the TADB database and the authentication from the TADBUsers database?

    Sorry, I tried to cut down the web.config to simplify as much as possible - the other connection strings are used in the application and are not necessary for login/membership/roles/etc, - the Users database links to all the providers. Also the app has many parts, - Book and NoPool are accessed by different users. You're probably better off ignoring them - Just there to show connectionstrings other than to the providers.

  • bkwdsarkie (6/25/2009)


    Praise the Lord, the application is up and running....

    From all the advise that I found - all the little pieces...I still don't know the definitive fix.

    But I changed the server machine.config file to not point to SQLEXPRESS and not to a .mdf file instead of the aspnetdb file I had created in SQL Server 2005.

    I also changed the provider application in machine.config to point to the application name that I had referenced in aspnetdb database. (My application is the only application running on this server.)

    Also there were 4 missing functions in the application database that did not transfer when I transfered the app database into SQL Server 2005. And of course those missing functions were the ones that I was using to test whether the app was working or not.

    Thanks for all the comments and recommendations. There are too many little pieces to getting an app such as this up and running.

    Good. 😀

    I like the trial-and-error method of programming, you learn more that way.

Viewing 13 posts - 1 through 12 (of 12 total)

You must be logged in to reply to this topic. Login to reply