I have no class this afternoon and I am playing with my computer again. I think of the problem that I did not solve yesterday. I feel a little uncomfortable. I have to solve the problem. ^_^.
I uninstalled the study instance installed yesterday and carefully studied the README file. According to the instructions in the file, I created a new file named MSDELog in the C root directory. log file, and then type "Setup SAPWD = chengbo/L * v C:/MSDELog. log SECURITYMODE = SQL "after the installation is complete, it is found that the installation is successful at the end of the log file, so you should just do it. Go to start-> Administrative Tools-> Services and start MSSQLSERVER. After restarting the computer, you will find the SQL Server Service Manager icon in the lower right corner. Green indicates that it is running.
The installation was successful, but there was no Northwind database. I searched the internet and found a solution on MSDN. After extracting the solution, I got three files: northwind. SQL #pubs. SQL #sampdbinstall.exe. Double-click sampdbinstall.exe and set "OK" in the TextBox after the Server to start installation. Open VS. Net and find the installed Northwind and pubs databases in SQL Server in the Server resource manager. Now, test whether the database is normal. Create a new WebForm and use the following code to change the Page_Load method in the cs file:
Private void Page_Load (object sender, System. EventArgs e)
{
SqlConnection Conn = New SqlConnection ("Server = (local); uid = sa; pwd = chengbo; Connection Timeout = 5; database = northwind ;");
Try
{
Sqldataadapter da = new sqldataadapter ("select firstname, lastname from employees ", Conn );
Dataset DS = new dataset ();
Da. Fill (DS );
Datagrid1.datasource = Ds;
Datagrid1.databind ();
}
Catch (exception ex)
{
Response. Write (ex. tostring ());
}
}
Press F5 and start the browser. The following table is displayed:
FirstName |
LastName |
Nancy |
Davolio |
Andrew |
Fuller |
Janet |
Leverling |
Margaret |
Peaco CK |
Steven |
Buchanan |
Michael |
Suyama |
Robert |
King |
Laura |
Callahan |
Anne |
Dodsworth |
Everything works! I hope this article will be helpful to anyone who has encountered the same problem.