This is an example for defining a foreign key relationship in Microsoft SQL Server (SQLEXPRESS). There are two tables: Salesperson and Customer (see below).  After the SalepersonID column is created in the Customer, it is important to define a foreign key relationship  to ensure the referential integrity.

A. The Salesperson table.

salesperson1

B. The Customer table.

customer

C. Foreign Key Relationship

Step 1. Select the SalespersonID column of the Customer table.

Step 2. Select the menu Table Designer >> Relationships…, then the “Foreign Key Relationships” window is desplayed. Locate and click the “Tables And Columns Specification”  property.

foreignkey11

Step 3. Click the little button (foreignkey2), then the “Tables and Columns” window is displayed. Make sure that the Foreign key table is Customer. So choose the SalespersonID column as the foreign key column. Then choose Salesperson as the Primary key table; and make its ID column as the primary key column.   

foreignkey3

Step 4. Click the OK button on the “Tables and Columns” window. Then, click the Close button on the “Foreign Key Relationships” window.

Here is the link: http://asp.dotnetheaven.com/howto/doc/adoplus/DatabaseTrans.aspx.  It has examples in C#, VB, and C++.

  1. Select the My Project file in Solution Explorer  (Figure 1).
  2. Select the Application category and change the Startup form from a list (Figure 2). 

myproject.JPG

<Figure 1>

startupform.JPG

<Figure 2>

It is suggested to manage SQLEXPRESS using SQL Server Management Studio Express, which is free from Microsoft.

1. Download SQL Server Management Studio Express. Go to:

http://www.microsoft.com/downloads/details.aspx?FamilyId=C243A5AE-4BD1-4E3D-94B8-5A0F62BF7796&DisplayLang=en

 2. After install it successfully, open the studio and log on your EQLEXPRESS server. Note that the server name must include EQLEXPRESS following your machine name and Windows Authentication should be used.

connectsql.jpg

3. The Object Explorer is displayed after a successful login.

tablesql.jpg

4. To create a database, right-click the Databases folder and select the New Database menu item.

5. To create a table, right-click the Tables folder and select the New Table menu item. 

  1. Set the column data type to int, bigint or smallint.
  2. Locate the (Is Identity) field in the Column Properties window.
  3. Set the (Is Identity)  value to be true.

autonumber.jpg

Suppose that your computer name is TAG302757  and  you create a database TESTDB in your local SQLExpress server. Then the connection string of the database is:

“Data Source=TAG302757\SQLEXPRESS;Initial Catalog=TESTDB;Integrated Security=True”

Note that there is a space  between the words Initial and Catalog; and the the connection string must be in the same line of your VB program.

You can use the statement Debug.WriteLine(“Web Service Debugging”) in your Web method to debug Web service program. However, the debug message “Web Service Debugging” may not be  shown when you run the service from another application project.  Follow the instructions below to fix this problem. 

  1. Make sure that you run the Web service from another project inside the same solution.
  2. Right-click the solution and select the Set StartUp Projects menu. Then the dialog shown in Figure 1 appears.
  3. Check Multiple startup projects and set the Action properties of your projects to be “start“.
  4. Start debugging.
  5. The dialog in Figure 2 may come up. Then click OK to continue.
  6. The debug message should be written in the Immediate or Output Window. If  you cannot see the Immediate Window, click the icon shown in Figure 3 in the tool bar.  

Figure 1:

startup.JPG

 

Figure 2:

debugdialog.JPG

 

Figure 3:

testing.JPG

In Microsoft Visual Studio 2005, port numbers of Visual Web Developer Web Server for tesing your Web service are dynamic by default. This is a problem for another project that creates a Web reference to this Web service. You can set up the Use Dynamic Ports property to false in  the Web service project to fix this problem (see the figure below)fixports.JPG.

If you cannot see the Data Sources window, select the menu Data>>Show Data Sources. If you cannot see the  Add New Data Sources icon, right-click the Data Sources window to use the popup menu.

Miscosoft Visual Studio 2005 comes with a personal SQL Server (or SQLEXPRESS).  You may get an error message when trying to add a connection to the SQLEXPRESS server for your project. The ”Add Connection” dialog usually shows your computer name in the “server name” field. You have to add a back slash and the “SQLEXPRESS” string for a sucessful connection (See the figure below).

 sqlexpress.JPG

Follow

Get every new post delivered to your Inbox.