Unable to open the requested database in login ' Patdb '. Login failed.
User ' xp-201005191456\huting ' login failed.
Problems encountered and solutions
1.vs2010 Connect sqlserver2008 Prompt to open the requested database in the login ' Patdb '. Login failed. User ' xp-201005191456\huting ' login failed.
---->
VS2010 Server Explorer-data connection----ADD Link---Server name select xp-201005191456\sqlexpress---Windows Province authentication---Connect to a database---test connection, Show successful Connection---"OK, you can
2. Right-click on the connected database on the Server Explorer, point properties. See the connection string
Data source=xp-201005191456\sqlexpress;initial catalog=patdb;integrated Security=true
Copy the above connection string into the VS2010 connection string---string connstring= "Data source=xp-201005191456\sqlexpress;initial catalog=patdb;i ntegrated security=true ";
Prompt error
\SQLExpress, indicating an unrecognized escape sequence
Workaround: String [email protected] "Data source=xp-201005191456\sqlexpress;initial catalog=patdb;integrated security=true "
Connection Database Successful
3 in the SQL SERVER table, insert a new field
ALTER TABLE doc_exa ADD column_b VARCHAR () NULL
Doc_exa is the table name
Column_b is the newly added field
VARCHAR (20) is the type and length of the newly added field
ALTER TABLE pat_info ADD Pet class VARCHAR (+) NULL
SELECT * FROM Pat_info
4 The field order of the SQL Server 2008 data table is adjusted after you save the prompt error
Start SQL Server Management Studio
The Tools menu----options----Designers (designer)----prevent saving changes that require you to recreate the table uncheck the box.
5 SQL How to insert data
Insert Intopat_info (number, pet category, name, origin, age, fur color, price, place of trade, notes) VALUES (5, ' dog ', ' Tibetan mastiff ', ' Inner Mongolia ', 4, ' white ', 4000, ' Beijing ', ' Hero Dog ')
Insertinto Table name (Field 1, Field 2, Field 3) values (the value of field 1, the value of field 2, the value of field 3);
SQL Server 2008 also extends the INSERT into syntax, allowing multiple rows to be inserted at once. As follows:
Insert into table name (Field 1, Field 2, Field 3)
Values (the value of field 1 is 1, the value of field 2 is 1, the value of field 3 is 1), (the value of field 1 is 2, the value of field 2 is 2, and the value of field 3 is 2),...
6 Pat Field
and query fields: 1-Pet Category 2-Origin 3-trade place 4--age 5--fur Color