%VOSWARNING% %META:TOPICPARENT{name="VirtInformixEntityFrameworkUsage"}% ---+++Visual Studio Windows DataGrid Form Application This article details the steps required to create a simple Visual Studio 2008 Windows Form application, with associated DataGridView control for displaying data in selected tables from the target database. 1 Launch the Visual Studio 2008 SP1 IDE. %BR%%BR%%BR%%BR% 1 Create a Web Application project by going to the File menu in Visual Studio and choosing New Project. %BR%%BR% 1 When the New Project window appears, choose either Visual Basic or Visual C# as your programming language.%BR%%BR% 1 Within the language category, click on Windows and select Windows Form Application from the right-hand panel. %BR%%BR% 1 Choose a name for the project, for example VirtWindowsFormApplication, and click OK. %BR%%BR%%BR%%BR% 1 In the Toolbox, expand Data Controls and drag the DataGridView control onto the form. %BR%%BR%%BR%%BR% 1 Click on the little arrow in the top right of the DataGridView control. This loads the DataGridView Task menu. %BR%%BR%%BR%%BR% 1 Click on the Choose Data Source list box. %BR%%BR%%BR%%BR% 1 Click on the Add Project Data Source link to connect to a data source. %BR%%BR%%BR%%BR% 1 In the Data Source Configuration Wizard dialog Choose Data Source Type page, select the Database data source type and click Next. %BR%%BR%%BR%%BR% 1 In the Data Source Configuration Wizard dialog Choose your Data Connection page,select the New Connection button. %BR%%BR%%BR%%BR% 1 In the Choose Data Source dialog, select the OpenLink Virtuoso Data Source from the list and click Continue. %BR%%BR%%BR%%BR% 1 In the Connection Properties dialog, specify the hostname, portno, username and password for the target Virtuoso Server and check the Save Password check box. %BR%%BR%%BR%%BR% 1 Select the Select Database From List radio button and choose stores_demo from the drop down list. %BR%%BR%%BR%%BR% 1 Press the Test Connection dialog to verify that the database is accessible. %BR%%BR%%BR%%BR% 1 Leave the default connect string name--stores_demoConnectionString--and click Next. %BR%%BR%%BR%%BR% 1 From the list of available tables returned for the stores_demo database, select the msgs table to be associated with the DataGridView control. %BR%%BR%%BR%%BR% 1 The columns names of the select table will be displayed in the the DataGridView. %BR%%BR%%BR%%BR% 1 Resize the Form and DataGridView to allow all columns to be visible, if possible. %BR%%BR%%BR%%BR% 1 To test the application, simply hit Ctrl+F5 within Visual Studio or select Start Debugging from the Debug menu. %BR%%BR%%BR%%BR% 1 The data from the msgs table will be displayed in the DataGrid. %BR%%BR%%BR%%BR% 1 To make the DataGridView updateable, you will need to manually add some code to the project along with a suitable control to invoke the code.%BR%%BR% Drag a Button control onto the form. %BR%%BR%%BR%%BR% 1 Right click on the Button and select Properties. %BR%%BR%%BR%%BR% 1 In the Properties view, edit the button's Text property to read Save Changes and its (Name) property to read saveChanges. %BR%%BR% %BR%%BR% 1 The button will now update to reflect these changes.%BR%%BR% NOTE: You will need to resize the button to make the new text visible. %BR%%BR%%BR%%BR% 1 Double click the new button to generate the required event handler. It should take you directly to the area of code that will execute when the button is clicked. %BR%%BR%%BR%%BR% 1 Edit the saveChanges_Click event handler code to include the following line.%BR%%BR% private void saveChanges_Click(object sender, EventArgs e) { this.msgsTableAdapter.Update(this.stores_demoDataSet.msgs); } %BR%%BR%%BR%%BR% 1 Now test the application again by hitting Ctrl+F5.%BR%%BR% Scroll to the empty row at the bottom and enter data for a new row. Then, select Save Changes which will write the new row back to the database.%BR%%BR% Updates and deletes can be performed similarly. %BR%%BR%%BR%%BR% 1 You can use Interactive ISQL to test that the changes that have been written. Interactive ISQL Interface is detailed in the [[VirtINFLinkingObjects][Linking Informix tables into OpenLink Virtuoso]] section. %BR%%BR%%BR%%BR% The task is now complete.