Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (19.37 KB, 3 trang )
2.1 Create a New SQL Server Database from Within Visual Studio .NET
Before working with a database, you have to be able to create it. Although you could use
code to do this, you would rather do it right from Visual Studio. How do you create a new
SQL Server database from within VS .NET?
Technique
As mentioned in the Introduction of this chapter, databases are basically file cabinets in
computers. That sounds pretty simplistic, but if you take the information that you store in
your file cabinets and transfer it over to the computer, you will end up with the same
elements.
You can physically create a new SQL Server database in several ways:
• Use SQL Server's Enterprise Manager to create the database.
• Programmatically create the database. You can do this by using T-SQL and SQL-
DMO, which are discussed in Chapters 6, "Creating Transact-SQL Commands,"
and 7, "Performing Common Database Tasks Using SQL-DMO," respectively.
• Use a menu in the Server Explorer of Visual Studio .NET to perform this task.
You will use the last option to complete the task presented in this How-To.
Steps
To get started with this How-To, leave Visual Studio at the Start Page when you open it.
Then place the cursor on the Server Explorer icon on the left side of the screen.
Note
The way that the Server Explorer and toolbox icons are laid out on the
side of the screen varies according to how you set the Profile option in
the My Profile settings on the Start Page-either Visual Studio Developer
or Visual Basic Developer.
After the Server Explorer has expanded, click on the plus symbol next to the Servers
node. Then you can follow down the tree by clicking on your computer's name
(SHADRACH2 in Figure 2.1) and then SQL Servers. Clicking on the name of the
computer again, you will see the list of current databases that are set up by default in the
Microsoft SQL Server Desktop Edition (MSDE). Although doing this was not necessary
to create a new database, it does give you an idea of where you can see various databases