ASP.net membership

Capodecina
Permabanned
Joined
31 Dec 2003
Posts
5,172
Location
Barrow-In-Furness
I've had a scan around and I can't seem to find much information. It's all well and good running the aspnet_regsql.exe to setup the database locally, but i'm working on a remote database and this can not change.

How can I configure this database so I can use the built-in membership controls?

Creating a custom one myself is for the time being not really plausable because i've onloy just started learning ASP.

It was suggested to me that I run the aspnet_regsql.exe locally and then copy the SQL code and execute it to remotely generate the tables etc? Is there anywhere I can find the SQL code for the aspnet_regsql.exe? I can't have an SQL server running on a local machine so I need another way to get it/do this.

It needs to work with the built-in ASP.net membership controls.

Grr :(
 
When you run the aspnet_regsql.exe you can specify the name of a different server to use, so it is possible.

Are you using SQL Server 2005?
 
I can't believe I didn't try putting in the server name before asking :o

Hold this space, i'll no doubt return shortly with a question.

Kevin I love you by the way.
 
How can I get a page to refresh when i've inserted data using a detailsview?

I have a GridView that needs to update on the same page with the information that has just been inserted, if you understand what I mean?

I've looked about for an autopostback but can't find it. I am solely using the detailsview for inserting here, no editing or displaying etc.
 
When i try administer the website and test the provider it says it can not establish a connection to the database.

The only provider I can test is "AspNetSqlProvider".
 
Wardie said:
How can I get a page to refresh when i've inserted data using a detailsview?

Easy, look at the events for your DetailsView.
Under the ItemInserted event add something like:

Code:
With [Name of your gridview]
       .DataBind()
End With

As for it not being able to establish the connection, you now need to configure the connection string in the web.config file.

The following link explains how to do it.
http://weblogs.asp.net/scottgu/archive/2005/08/25/423703.aspx
 
Here's what I have in my web.config file:

Code:
<connectionStrings>
  <add name="TrainingConnectionString" connectionString="Data Source=GLKAS0312;Initial Catalog=Training;Persist Security Info=True;User ID=****;Password=****"
   providerName="System.Data.SqlClient" />
 </connectionStrings>

<membership defaultProvider="MyMembershipProvider">
      <providers >
        <clear/>
        <add connectionStringName="TrainingConnectionString"
         name="MyMembershipProvider" type="System.Web.Security.SqlMembershipProvider"/>
      </providers>
    </membership>

With the membership part added there is now no providers under the provider list when I try administer it.

:(
 
Cheers :)

The thing is, I still haven't really worked out how to display data how I originally intended for this application. That could be a problem...
 
Wardie said:
The thing is, I still haven't really worked out how to display data how I originally intended for this application. That could be a problem...

Depends on how you have eventually set up your database.
 
As I was going through the security wizard setup, I got a little way in then received this error:

An error was encountered. Please return to the previous page and try again.

The following message may help in diagnosing the problem: Unable to connect to SQL Server database. at System.Web.Administration.WebAdminPage.CallWebAdminHelperMethod(Boolean isMembership, String methodName, Object[] parameters, Type[] paramTypes) at ASP.security_wizard_wizardpermission_ascx.OnInit(EventArgs e) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

I got this just after I had selected I wished to use Roles.
 
Last edited:
I've got the membership working now, but I really need to find some guide or tutorial on how to actually obtain UserIDs and input them into the database. Using sessions or whatever, i'm new to all this and I can't find a thing.

Can't seem to find any tutorials on it anywhere :(
 
So you managed to sort out the membership. I have not done it via a remote SQL Server before, so didn't know what the problem was. :(

Anyway, what are you trying to do?

Get the current logged on user and put it into the database?

Are you using the CreateUserWizard form on the aspx page?
 
I'm trying to learn and work out to how I have different users input data input the system and have their userid stored along with the data.

At the moment I have just created the design on the website and created a version which works but without different users.

Now the membership is working I need to update the rest of the application to suit this.

Is that any clearer?
 
OK, so you have set up all your user and role memberships.
They then login to the site, make changes to data in another database.
But when making changes you want to log the userid they logged on with?
A bit like an audit log/trail?
 
I've really not explained this welllll ha-ha.

Can you remmeber what i'm trying to create?

It's basically an application which will allow users to log the ammount of time they have spent on a task.

At the moment it works without using users, so no userid is stored, just a unique ID of the record and then the rest of the information.

I've not got the ASP.net membership setup so I need to now change the application so that it works using users.
 
To start with you will need to setup the asp.net membership and create the users and roles you need for the application. You should be able to do this in VWD (Website -> ASP.NET Configuration).

Then in an aspx page, use the login controls in the toolbox. There is one called 'LoginName' , you could use that to get the UserID of the person logged in.
 
The SQL Database is being a pain in the bum!

Wont let me make a relationship to the UserName table, the fields are exactly the same type and I tried deleting all data first too. Grrr!

I can't seem to workout how I can use LoginName to get the UserName into the textbox? I'm guessing something like:

TextBox1.Text = LoginName1

I don't know where this code goes though, because if I put it on page load it says TextBox1 is not declared, and LoginName too.

ARGHHHHHHHH

lol
 
Where is the textbox, is it within a GridView/DetailsView?

Put it under another event, I've put one recently under the textbox event 'TextChanged'.
 
Last edited:
Back
Top Bottom