Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create user stored procedure

Status
Not open for further replies.

adrianjohnson

Programmer
May 16, 2002
145
GB
I'm trying to use the stored procedure that asp.net uses to create a new user on a web database. The reason I'm doing this is because the user wants to export a list of over 400 username and passwords from Excel into the aspnet_users table without having to create new users manually.

So, I've created a C# desktop program that reads the spreadsheet and creates new users based on the data. The code is:

Code:
Guid newUser = new Guid();               
SqlCommand addCommand = new SqlCommand("aspnet_Membership_CreateUser", Data.dbConnection);
addCommand.CommandType = CommandType.StoredProcedure;
addCommand.Parameters.Add(new SqlParameter("@ApplicationName", "AppName"));
addCommand.Parameters.Add(new SqlParameter("@UserName", "testuser2"));
addCommand.Parameters.Add(new SqlParameter("@Password", "password"));
addCommand.Parameters.Add(new SqlParameter("@PasswordSalt", newsalt));
addCommand.Parameters.Add(new SqlParameter("@Email", newemail));
addCommand.Parameters.Add(new SqlParameter("@PasswordQuestion", "Capital of England?"));
addCommand.Parameters.Add(new SqlParameter("@PasswordAnswer", "London"));
addCommand.Parameters.Add(new SqlParameter("@IsApproved", 1));
addCommand.Parameters.Add(new SqlParameter("@CurrentTimeUtc", DateTime.Now));
addCommand.Parameters.Add(new SqlParameter("@UserId", newUser));

When it runs, I get an error that a UserId is expected. Any ideas on how I can get around this please?

Thanks,

Adrian
 
Guid newUser = Guid.NewGuid(); or something like that. it's a static function of the Guid object

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top