Today, I went to the customer to implement the project. I had to talk about using the demo data for testing. Later, I will temporarily import the current user. No
With a laptop, the customer's server only has an ordinary Program For general data initialization, SQL Server 2000 and Excel can solve the problem.
But now the system has introduced Asp.net membership as the user model, so the import needs to be different. The main idea is as follows: first put the user into a common text file,
Read in the program, pay attention to the Chinese encoding, and then use membership to create a user. In this way, you do not need to analyze the relationship again. In fact, the relationship between membership tables is clear.
String filename = "C: \ Name ";
// Open the file and display its content
Streamreader reader = NULL;
Try
{
Reader = new streamreader (filename, system. Text. encoding. Default );
For (string line = reader. Readline (); line! = NULL; line = reader. Readline ())
{
// General information of the registered user
String username = line;
String Password = "123456 ";
String email = username + "sf.com ";
String question = "Where is SF ";
String answer = "jiangsusuzhou ";
membershipcreatestatus status;
membershipuser newuser = membership. createuser (username. trim (), password. trim (), email. trim (), question. trim (), answer. trim (), true, out status);
// registered user Extension Information
If (status = membershipcreatestatus. success)
{< br> console. writeline ("Reg OK");
console. writeline (line);
}else
{< br> console. writeline ("Reg failed");
}
}
}
Catch (ioexception E)
{
Console. writeline (E. Message );
}
If (reader! = NULL)
Reader. Close ();