Note Column Name is a placeholder for the name of the column of a table in the database where the primary key constraint exists.
If you use the navigation buttons to move through the records of a database table on the data form, you may receive the following error message:
- The primary column
- A column that does not permit NULLS
Steps to reproduce the behavior
Create a Microsoft Windows application
- Start Microsoft Visual Studio .NET or Microsoft Visual Studio 2005.
- On the File menu, point to
New, and then click Project. The New Project dialog box appears.
- Under Project Types, click Visual C# Projects.
Note In Visual Studio 2005, click Visual C#.
- Under Templates, click Windows Application.
- In the Name box, type the name of the project.
- In the Location box, type the location where you want to save the project.
- Click OK. By default, Form1.cs is added to the project.
Add a Data Form to the Windows application
- In Solution Explorer, right-click the project, point to
Add, and then click Add New Item. The Add New Item dialog box appears.
Note In Visual Studio 2005, click New Items. The New Items dialog box appears
- Under Templates, click Data Form Wizard.
- In the Name box, type the name of the Data Form.
- Click Open. The welcome screen of the Data Form Wizard appears.
- Click Next.
- On the Choose the dataset you want to use page, type a dataset name in the Create a new dataset named box, and then click Next.
- On the Choose a data connection page, click New Connection. The Data Link Properties dialog box appears.
- Set up a connection to the database from the Data Form Wizard:
- In the Data Link Properties dialog box, click the Connection tab.
- In the Select or enter a server name box, select the name of the server where your database is located.
- Under Enter information to log on to the server, click to select the Use Windows NT Integrated security option.
- In the Select the database on the server box, select the database that you want to use.
- Click OK.
- Click Next.
- On the Choose tables or views page, select the tables that you want to use.
- Click Next.
- On the Choose tables and columns to display on the form page, click to clear the check box for the primary key on the column that appears in the Columns box, and then click Next.
Note You can also click to clear the check box for the column that does not permit NULLS.
- On the Choose the display stylepage, click to select the Single record in individual controls option. Notice that the Add-Creates a new recordoption is not disabled.
- Click Finish.
Set the Data Form as the Startup Object of the project
- In Solution Explorer, click
- On the View menu, click
- In the code view of Form1.cs, locate the following line of code. This line is the main entry point for the application.
static void Main()
- In the Main function, replace the existing code with the following code.
Verify the Data Form
- On the Debug menu, click
Start. DataForm1 appears.
Load. The records from the table that is selected in the database appear in the controls.
- Click Add. All the controls on DataForm1 are cleared.
- Type valid data in the controls that appear on DataForm1, and then click Update. You receive the message that appears in the "Symptoms" section of this article.
- Click the navigation buttons to move through the records. You receive the error message that appears in the "Symptoms" section of this article.