adrianjohnson
Programmer
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:
When it runs, I get an error that a UserId is expected. Any ideas on how I can get around this please?
Thanks,
Adrian
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