Home All Groups Group Topic Archive Search About
Author
2 Nov 2007 8:47 PM
darrel
I'm still trying to wrap my head around how VS.net, SQL Express, and the
built in membership provider all works.

At home I've been struggling to get it all to work. I constantly run into
errors with the ASP.net configuration wizard.

So, at work, I thought I'd try and go through the same steps.

I have:

1) Created a new web site project
2) Opened ASP.net Configuration Wizard
3) Set up the provider
4) Enabled roles
5) added a user.

It all worked!

*BUT*...where is my DB?

I didn't select a specific DB. There's nothing in my app_data folder. Where
in the world is all this membership data now being stored?

To ask the question in a different way: How am I suppose to go about setting
up my own local DB in app_data using swl express and have my application use
THAT db to store the information?

-Darrel

Author
2 Nov 2007 8:59 PM
sloan
Read this blog:
http://weblogs.asp.net/scottgu/archive/2005/08/25/423703.aspx

and at the end about this thing
LocalSqlServer

and it'll start to clue you in as to what is going on.


Google LocalSqlServer as well, and stuff will start popping up.

....

Also, before you make any config file changes, run this code:

private void LoadData()
{

    ConnectionStringSettingsCollection connectionStrings =
ConfigurationManager.ConnectionStrings;

    ConnectionStringSettings connection;
    foreach ( connection in connectionStrings) {



        string connectionStringName = connection.Name;  // look for
LocalSqlServer HERE
        string connectionString = connection.ConnectionString;
        string providerName = connection.ProviderName;

        Debug.Print(connectionStringName);
    }







}

and it'll tell you where's is coming from for sure.




Show quote
"darrel" <notr***@nowhere.com> wrote in message
news:%2358xeGZHIHA.3768@TK2MSFTNGP06.phx.gbl...
> I'm still trying to wrap my head around how VS.net, SQL Express, and the
> built in membership provider all works.
>
> At home I've been struggling to get it all to work. I constantly run into
> errors with the ASP.net configuration wizard.
>
> So, at work, I thought I'd try and go through the same steps.
>
> I have:
>
> 1) Created a new web site project
> 2) Opened ASP.net Configuration Wizard
> 3) Set up the provider
> 4) Enabled roles
> 5) added a user.
>
> It all worked!
>
> *BUT*...where is my DB?
>
> I didn't select a specific DB. There's nothing in my app_data folder.
> Where in the world is all this membership data now being stored?
>
> To ask the question in a different way: How am I suppose to go about
> setting up my own local DB in app_data using swl express and have my
> application use THAT db to store the information?
>
> -Darrel
>
Author
2 Nov 2007 9:38 PM
darrel
I see that link a lot, but it seems to refer to full SQL Server, rather than
SQL Express. Am I not reading that right?

My main hangup is with this comment:

"Out of the box, most of the ASP.NET 2.0 application services are configured
to use the built-in SQL Express provider.  This provider will automatically
create and provision a new database for you the first time you use one of
these application services, and provides a pretty easy way to get started
without a lot of setup hassles"

It sure SOUNDS easy, but I'm completely lost! ;0)

I did read the part about the connection string.

I went ahead and made a new web project.

This time I used this process:

1) Added a new SQL db to App_data folder "testdb.mdf"
2) Went into my web.config and added this connection string:

<connectionStrings>
<remove name="LocalSqlServer"/>
<add name="LocalSqlServer" connectionString="Data Source=localhost;Initial
Catalog=testdb.mdf;Integrated Security=True"
providerName="System.Data.SqlClient"/>
</connectionStrings>

3) Went to ASP.net configruation wizard
4) Clicked on Provider
5) chose and tested AspNetSqlProvider

This fails with:

Could not establish a connection to the database.
If you have not yet created the SQL Server database, exit the Web Site
Administration tool, use the aspnet_regsql command-line utility to create
and configure the database, and then return to this tool to set the
provider.

6) ran aspnet_regsql
7) by default it points at my computer as the server
8) BUT...if I try to select a DB, I get this error:
---------------------------
Connection failed
---------------------------
Failed to query a list of database names from the SQL server.
An error has occurred while establishing a connection to the server.  When
connecting to SQL Server 2005, this failure may be caused by the fact that
under the default settings SQL Server does not allow remote connections.
(provider: Named Pipes Provider, error: 40 - Could not open a connection to
SQL Server)
---------------------------
OK
---------------------------


so...I'm still stuck.

I'll try running that code snipped you provided. Thanks for that!

-Darrel
Author
2 Nov 2007 9:43 PM
darrel
> and it'll tell you where's is coming from for sure.

Alas, I'm not a C# person. The translator came out with this, but doesn't
work in VB:

Private Sub LoadData()
    ConnectionStringSettingsCollection connectionStrings =
    ConfigurationManager.ConnectionStrings()
    Dim connection As ConnectionStringSettings

    For Each connection In connectionStrings


        Dim connectionStringName As String = connection.Name ' look for
        LocalSqlServer(HERE)
        Dim connectionString As String = connection.ConnectionString
        Dim providerName As String = connection.ProviderName
    Debug.Print(connectionStringName)
    Next
End Sub
Author
5 Nov 2007 2:44 PM
sloan
Ok.

Kinda what I was getting at was this:

<connectionStrings>
</connectionStrings>

If you don't put anything in there...then "LocalSqlServer" should exist
already.

The reason you put in the "<remove xxxxxxxxxx/>" is so you override the
default.
But if you go ahead and don't do the <remove>, then you should see the
default.


So by using the code I gave you, you can then see what the connection string
is.  Aka, you'll get a report of the connection.ConnectionString.

...

Ok, the c#/vb.net thing.

I don't see an issue with the translation.

You can temporarily make a C# web project, just to get the info.

Make sure you have the System.Configuration assembly added to your project.
(via the "Add Reference" thing).


Private Sub LoadData()
    ConnectionStringSettingsCollection connectionStrings =
ConfigurationManager.ConnectionStrings()

        Dim connectionStringName As String = string.Empty
        Dim connectionString As String = string.Empty
        Dim providerName As String  = string.Empty

    For Each connection as ConnectionStringSettings  In connectionStrings

        connectionStringName As String = connection.Name
        connectionString As String = connection.ConnectionString
        providerName As String = connection.ProviderName

        Debug.Print(connectionStringName)
    Next
End Sub


I don't know, try that.  I didn't really change anything.

Look up the objects in msdn..if you need vb syntax.




Show quote
"darrel" <notr***@nowhere.com> wrote in message
news:Ofj0alZHIHA.1164@TK2MSFTNGP02.phx.gbl...
>> and it'll tell you where's is coming from for sure.
>
> Alas, I'm not a C# person. The translator came out with this, but doesn't
> work in VB:
>
> Private Sub LoadData()
>    ConnectionStringSettingsCollection connectionStrings =
>    ConfigurationManager.ConnectionStrings()
>    Dim connection As ConnectionStringSettings
>
>    For Each connection as  In connectionStrings
>
>
>        Dim connectionStringName As String = connection.Name ' look for
>        LocalSqlServer(HERE)
>        Dim connectionString As String = connection.ConnectionString
>        Dim providerName As String = connection.ProviderName
>    Debug.Print(connectionStringName)
>    Next
> End Sub
>
>
>

AddThis Social Bookmark Button