Using Microsoft SQL Server 2000 and/or MSDE 2000 (the Microsoft SQL Server Desktop Engine) with Visual Studio .Net 2003

by Jeff Charles

Updated about 12/31/2004

Return to Home Page


Some key points:

(1) You may have to enter your computer\instance in the Server combo box of MSDE's SQL Server Service Manager dialog box (it may not find them automatically).
(2) If you use both computer name and MSDE instance name, you have to separate them with a backslash (\), NOT a forward slash (/).
(3) You may have to use the Connect to Database button in Visual Studio's Server Explorer, to connect and make the databases visible.
Further details and references are in this page's content below.



Some preliminary reference information:

 

To find out your computer name, to use when running osql statements:

      My Computer - right click

       Properties - click

        Computer Name tab - click

         Full computer name: antec2003

      You can also find your computer name in Visual Studio:

       View->Server Explorer

        Expand the line Servers and you should see your computer name.

         If you expand subsequent lines, it will also be included under

            SQL Servers, in front of the backslash and the instance name.

 

To check on what services are running (e.g. SQL Server):

      My Computer - right click

       Manage - click

        Services and Applications - double click

         Services - double click

          Look for service name 'MSSQL$VSDOTNET'

                  (shows status as "started" if it's running, not stopped)

            - double click on that service name

           Log On tab - click

            Allow service to interact with desktop - check this box?

                  (I don't know if this checkbox helps anythng, but it might)

 

 

====================

 

Using MSDE - the Microsoft SQL Server Desktop Engine ...

 

Download MSDE:

      http://www.microsoft.com/sql/msde/downloads/default.asp

       Use link 'Download MSDE 2000 Release A' to go to

        http://www.microsoft.com/sql/msde/downloads/download.asp

       Select language and click 'Go' to go to the next page

       At bottom of that page, click the link 'MSDE2000A.exe'

        to download the file MSDE2000A.exe.

 

      (or from http://www.microsoft.com/sql/msde/downloads/default.asp

       Use link 'SQL Server 2000 Service Pack 3a' to go to

        http://www.microsoft.com/sql/downloads/2000/sp3.asp

       Select language and click 'Go' to go to the next page

       At bottom of that page, click the link 'sql2kdesksp3.exe'

        to download the file sql2kdesksp3.exe, instead of MSDE2000A.exe.

        Either one should work, for a new installation.)

 

      Also from http://www.microsoft.com/sql/msde/downloads/default.asp

       Use link 'Northwind and pubs Sample Databases' to go to

        the next page containing sample database downloads.

       Download the sample database file SQL2000SampleDb.msi.

 

Expand the files:

      Double click on the downloaded file MSDE2000A.exe to expand the files.

       InstallShield puts them in a default folder called c:\MSDERelA.

       It should say 'The package has been delivered successfully".

      In c:\MSDERelA there is a readme file called ReadmeMSDE2000A.htm'

       if you want more info.  It also has an addendum online at

       http://support.microsoft.com/?kbid=829925.

       However, I will describe the MSDE setup later;

       the document references may not be needed.

 

      Double click on the sample database downloaded file SQL2000SampleDb.msi

       to expand the sample database script files.

      The Windows installer wizard puts the sample database scripts in

       c:\Program Files\Microsoft SQL Server 2000 Sample Database Scripts.

       (And they then appear in the Control Panel /

         Add or Remove Programs list.)

      The wizard says to follow the instructions in the readme

       to complete the installation.  The readme is called

       ReadMe_SQL2000SampleDbScripts.htm, in the directory noted above.

       However, I will describe the sample database setup later;

       the document references may not be needed.

 

      (If using the book 'Murach's C#', by Joel Murach and Doug Lowe,

       then after downloading the book's support files

       at murach.com's site as cshp_allfiles2003.exe, double click on

       that downloaded file to unzip the files into c:\Murach\C#.NET

       and c:\C#.NET.)

 

Setup:

      To set up MSDE:

            Go to a command prompt

             (i.e., Start->All Programs->Accessories->Command Prompt).

            Use the cd command to change directories as follows:

                  cd c:\MSDERelA

            Run this command:

                  setup instancename=vsdotnet sapwd=myownpwd

             where myownpwd is the password you want to use as

             your system administrator password.

            (Further info on MSDE setup is at

                  http://msdn.microsoft.com/library

                        /en-us/distsql/distsql_84xl.asp?frame=true

             which is the same as

                  http://go.microsoft.com/fwlink/?LinkID=13960,

             and you can also see

                  http://go.microsoft.com/fwlink/?linkid=13962

             although that page may be unreliable.)

            The Windows installer will complete the installation and

             display a message stating that you must restart your system

             for the changes to MSDE to take effect.  After saving any

             open data files, restart your system.

            There will now be a directory called

                  c:\Program Files\Microsoft SQL Server

            Your instancename should appear under that as:

                  c:\Program Files\Microsoft SQL Server\MSSQL$VSDOTNET

 

            Go to Start->All Programs->Startup->Service Manager.

            The SQL Server Service Manager window will open.

            The 'Server' combo box is empty.

             And the status bar at the bottom says 'Not Connected - \\'.

             If you click or double click on the

             'Start/Continue' arrow button at this point,

             (and/or click the 'Refresh services' button), a message

             will say 'The specified server name is invalid',

             or 'This service control cannot be completed as no service has

             been selected', or nothing will happen.

            Type into the 'Server' combo box:

                  antec2003\vsdotnet

             (using a backslash, not a forward slash)

             where antec2003 is your computer name (see instructions at the

             top of this document to find your computer name)

             and vsdotnet is the instancename of your MSDE instance

             (used in the MSDE setup command previously).

            Note: if a forward slash is used to separate the computer name

             and the instance name, you'll get an error message saying

             'The network path was not found', when you click the

             'Refresh services' button.  You must use a backslash,

             not a forward slash.

            Click the 'Refresh services' button.

            The status bar at the bottom of the window will say:

                  Running - \\antec2003\vsdotnet - MSSQLServer

             where antec2003 is your computer name and vsdotnet

             is your MSDE instance name.

            If you check on what services are running, at this point,

             (see instructions near top of this document),

             there will be a service with the name 'MSSQL$VSDOTNOT'

             (where VSDOTNET is your instance name)

             and its status will be 'Started'.

            You can also see the services that are running by going into

             Visual Studio .NET 2003, Server Explorer.  Expand the

             lines for: Servers, antec2003 [your computer name],

             Services.  Then the service MSSQL$VSDOTNET will show below

             that (where VSDOTNET is your instance name).

            Also, in Visual Studio, Server Explorer, you can expand the

             lines for: Servers, antec2003 [your computer name],

             SQL Servers, ANTEC2003\VSDOTNET [your computer and instance].

             Under that you will see some databases,

             such as master, model, msdb, and tempdb.

             You will not yet see the Northwind or pubs databases--

             we will set them up shortly.

 

      To set up the Sample Databases (from SQL Server--Northwind and pubs):

            Go to a command prompt

             (i.e., Start->All Programs->Accessories->Command Prompt).

            Use the cd command to change directories as follows:

                  cd c:\Program Files

                        \Microsoft SQL Server 2000 Sample Database Scripts

            Do a 'dir' command and make sure that instnwnd.sql and

             instpubs.sql files are there.

            Run this ODBC SQL (osql) command:

                  osql -E -S antec2003\vsdotnet -i instpubs.sql

                        -o myoutputlog1.txt

                  where antec2003\vsdotnet is your computer\instance name

                  (be sure to use a backslash, not a forward slash).

                  Log file name numbers can be incremented on later runs.

                  The -i and -o files are the input and output files.

                  Note: if you use a forward slash, you'll get error

                        messages in the output log file as follows:

                   [DBNETLIB]SQL Server does not exist or access denied.

                   [DBNETLIB]ConnectionOpen (Connect()).

                  Changed the forward slash to a backslash.

                  Got an error:

                   Could not obtain exclusive lock on database 'MODEL'.

                   Retry the operation later.

                  Closed Visual Studio, and the SQL Server Service Manager.

                  Reran the osql command as above.  Checked the output log

                        file.  It looks okay.

                  Now when you go back into Visual Studio, Server Explorer,

                   and expand the lines: Servers, antec2003 [your computer

                   name], SQL Servers, ANTEC2003\VSDOTNET

                   [your computer\instance], you should see a new database

                   listed, called 'pubs'.  It contains tables such as

                   publishers, authors, and jobs.

                   (If necessary, you can click the 'Refresh'

                   button in Visual Studio--Server Explorer, or

                   close and reopen Visual Studio, or stop and start

                   the MSDE server, or reboot your computer.)

            Run this ODBC SQL command (similar to above, only for the

             Northwind database, instead of the pubs database)

             after closing Visual Studio to avoid conflict:

                  osql -E -S antec2003\vsdotnet -i instnwnd.sql

                        -o myoutputlog2.txt

                  where antec2003\vsdotnet is your computer\instance name

                  (be sure to use a backslash, not a forward slash).

                  Ran the osql command.  Checked the output log

                        file.  It looks okay.

                  Now when you go back into Visual Studio, Server Explorer,

                   and expand the lines: Servers, antec2003 [your computer

                   name], SQL Servers, ANTEC2003\VSDOTNET

                   [your computer\instance], you should see a new database

                   listed, called 'Northwind'.  It contains tables such as

                   Orders, Products, and Customers.

                   (If necessary, you can click the 'Refresh'

                   button in Visual Studio--Server Explorer, or

                   close and reopen Visual Studio, or stop and start

                   the MSDE server, or reboot your computer.)

            (Further info on osql is at

                  http://support.microsoft.com/default.aspx?scid=

                        kb;en-us;325003

             and

                  http://msdn.microsoft.com/library/en-us/coprompt

                        /cp_osql_1wxl.asp?frame=true . )

 

      To set up the sample databases from the VB textbook CD

            (Advanced Programming Using Visual Basic .NET,

            by Bradley and Millspaugh):

             Use the instructions in the file 'InstallingSQLServerFiles.doc'

                  on the textbook CD.

 

      To set up the sample databases from the book 'Murach's C#':

            Use the instructions in the support files download for the book,

                  after unzipping the download file.  The instruction file

                  name is 'Readme for 2003 download.pdf'.

            Or you may have to just copy the .mdf and .ldf files from the

                  Murach database directory over to

                  'c:\Program Files\Microsoft SQL Server\

                  MSSQL$VSDOTNET\Data' (if you used the normal naming;

                  where VSDOTNET is your MSDE instance name), and then

                  use the 'Connect to Database' button in Server Explorer

                  as described below under 'Operation'.

 

Operation:

      Whenever you restart your machine, if the server icon exists in the

       Notification Area on the right side of the task bar, double-click

       it to open the SQL Server Service Manager window.  If the icon does

       not display in the Notification Area, open the SQL Server Service

       Manager by using Start->All Programs->Startup->Service Manager.

      If the Server combo box is empty, type in

            antec2003\vsdotnet

       (your computer\instance) into the Server combo box

       and click on the 'Refresh services' button.

       The status bar at the bottom of the window should then say:

            Running - \\antec2003\vsdotnet - MSSQLServer

       (using your computer name and MSDE instance name).

       If necessary to get it running, close Visual Studio,

       click the 'Refresh services' button, and then

       click or double click the 'Start/Continue' arrow button.

      In Visual Studio, Server Explorer, you should be able to

       double click on a data base and have its data rows display in the

       Visual Studio edit area.  That is, you should be able to

       expand the lines: Servers, antec2003 [your computer name],

       SQL Servers, ANTEC2003\VSDOTNET [your computer\instance],

       Northwind [the database name you want to use], Tables.

       Then you should be able to double click on a table

       (for example, Products) and have its rows display.

      If not, and you get a login screen instead,

       then click on the database name to highlight it,

       and then click on the 'Connect to Database' button

       at the top of the Visual Studio--Server Explorer window.

       A 'Data Link Properties' dialog box will appear.

       On the 'Connection' tab page, fill in antec2003\vsdotnet

       (your compter\instance) in item 1, choose 'Use Windows NT

       Integrated security' in item 2, and choose

       'Attach a database file as a database name' in item 3

       and fill in the database name in the first box below that

       (for example, Northwind) and navigate to

       the database's .mdf file in the bottom box.

       (The mdf file should be in 'c:\Program Files\Microsoft SQL Server\

       MSSQL$VSDOTNET\Data\northwind.mdf' if you used

       the normal naming; where VSDOTNET is your MSDE instance name,

       and northwind.mdf is the file name for the database you want.)

       Then click the 'Test Connection' button and make sure

       you get the message 'Test connection succeeded'.

       Now when you expand the lines in Server Explorer and

       double click on the database's table name (such as Products),

       the table should open in the Visual Studio edit area.

       (You can close it without closing all of Visual Studio

       by using the appropriate small 'x' close button for that document.)

 

For Windows XP Professional Service Pack 2 (August 2004), see

      'Microsoft SQL Server - FAQ: How Windows XP Service Pack 2 (SP2)

       Affects SQL Server and MSDE', at:

            http://www.microsoft.com/sql/techinfo/administration

                  /2000/security/winxpsp2faq.asp

 

For info about applying SQL Server Service Pack 3a,

      including on trial software, see:

            http://www.microsoft.com/sql/downloads/2000/sp3.asp

      This web page states, among other things, that:

            SQL Server 2000 SP3a:

            Improves serviceability for SQL Server 2000 Evaluation

             Edition. SP3a enables service pack upgrades for trial

             software. In the past, service packs have not been

             applicable to trial software.

 

Return to top of page        Return to Home Page

Copyright © 2004 Jeffrey A. Charles; all rights reserved.