|
|
Want to know more about Packt's Article Network? Interested in contributing your article ideas? Please visit our FAQ for more information. See More BROWSE
All Titles WordPress Web Services SOA BPEL Web Graphics & Video Web Development RAW Portugues, Espanol, Italiano, French PHP/MySQL Oracle Open Source Networking & Telephony Moodle Microsoft & .NET Linux Servers jQuery Joomla! JBoss Java e-Learning e-Commerce Dynamics Drupal CRM Cookbook Content Management Beginner Guides Architecture and Analysis AJAX Future Titles Recently Published Titles Postgres is the well known and most used Open Source OLTP database available today. EnterpriseDB sits atop Postgres and leverages it to provide enterprise capabilities to Postgres users. EnterpriseDB is available for Windows platform as well. It has most of the necessary features of an enterprise class such as advanced development, monitoring, migration and administrative tools with a stable environment. It also has plug-in capabilities for Oracle. In the present form EnterpriseDB claims cost effectiveness versus Oracle and better scalability than MySQL. It can easily integrate with most applications such as Java, Ajax, Ruby, Drupal etc. This article by Dr. Jayaram Krishnaswamy mainly describes the installation of EnterpriseDB and the basic features to get started on this important database product. See More |
Creating a VB.NET application with EnterpriseDB
Overview of the tutorialYou will begin by creating an ODBC datasource for accessing data on the Postgres server. Using the User DSN created you will be connecting to the Postgres server data. You will derive a dataset from the table which you will be using to display in a datagrid view on a form in a windows application. We start with the Categories table that was migrated from MS SQL Server 2008. This table with all of its columns is shown in the Postgres studio in the next figure.
Creating the ODBC DSNNavigate to Start | Control Panel | Administrative Tools | Data Sources (ODBC) to bring up the ODBC Database Manager window.
Click on Add.... In the Create New Data Source scroll down to EnterpriseDB 8.2 under the list heading Name as shown.
Click Finish. The EnterpriseDB ODBC Driver page gets displayed as shown. Accept the default name for the Data Source(DSN) or, if you prefer, change the name. Here the default is accepted. The Database, Server, User Name, Port and the Password should all be available to you [Read article 1].
If you click on the option button Datasource you display a window with two pages as shown. Make no changes to the pages and accept defaults but make sure you review the pages.
Click OK and you will be back in the EnterpriseDB Driver window. If you click on the button Global the Global Settings window gets displayed (not shown). These are logging options as the page describes. Click Cancel to the Global Settings window. Click on the Test button and verify that the connection was successful. Click on the Save button and save the DSN under the list heading User DSN. The DSN EnterpriseDB enters the list of DSN's created as shown here.
Create a Windows Forms application and Establish a connection to PostgresOpen Visual Studio 2008 from its shortcut. Click File | New | Project... and open the New Project window. Choose a windows forms project for Framework 2.0. Besides Framework 2.0 you can also create projects in other versions in Visual Studio 2008. In Server Explorer window double click the Connection icon as shown.
This brings up the Add Connection window as shown.
Click on Change... button to display the Change Data Source window. Scroll up and select Microsoft ODBC Data Source as shown.
Click OK. Click on the drop-down handle for the option Use user or system data source name and choose EnterpriseDB you created earlier as shown.
Insert User Name and Password and click on the Test Connection button. You should get a connection succeeded message as shown.
Click OK on the message screen as well as to the add connection window. The connection appears in the Visual Studio 2008 in the Server Explorer as shown.
Small Business Server 2008 – Installation, Migration, and Configuration
Displaying data from the tableDrag and drop a DataGridView under Data in the Toolbox onto the form as shown (shown with SmartTasks handle clicked)
Click on Choose Data Source handle to display a drop-down menu as shown below.
Click on Add Project Data Source at the bottom. This displays the Choose a Data Source Type page of the Data Source Configuration Wizard.
Accept the default datasource type and click Next. In the Choose Your Data Connection page of the wizard choose the ODBC.localhost.PGNorthwind as shown in the drop-down list.
Click Next in the page that gets displayed and accept the default to save the connection string to the application configuration file as shown.
Click Next. In the Choose Your Database Objects page, expand Tables and choose the categories table as shown. The default Dataset name can be changed. Herein the default is accepted.
Click Finish. The DatagridView on Form1 gets displayed with two columns and a row but can be extended to the right by using drag handles to reveal all the four columns as shown. Three other objects PGNorthwindDataSet, CategoriesBindingSource, and CategoriesTableAdapter are also added to the control tray as shown. The PGNorthwindDataset.xsd file gets added to the project.
Now build the project and run. The Form 1 gets displayed with the data from the PGNorthwind database as shown.
In the design view of the form few more tasks have been added as shown. Here you can Add Query... to filter the data displayed; Edit the details of the columns and you can choose to add a column if you had chosen fewer columns from the original table.
For example, Edit Column brings up its editor as shown where you can make changes to the styles if you desire to do so. The next figure shows slightly modified form by editing the columns and resizing the cell heights as shown.
SummaryA step-by-step procedure was described to display the data stored in a table in the Postgres database in a Windows Forms application. Procedure to create an ODBC DSN was also described. Using this ODBC DSN a connection was established to the Postgres server in Visual Studio 2008. If you have read this article you may be interested to view :
Small Business Server 2008 – Installation, Migration, and Configuration
About the AuthorDr. Jay Krishnaswamy is a graduate of the Indian Institute of Science, Bangalore writes on database and web development related topics to several computer programming related web sites. He is an active participant in several forums and discussion groups. Before working in the IT industry as a Microsoft Certified Trainer and a Siebel Certified consultant he taught at several institutes of technology and universities in India, Australia, Brazil and the USA. Links to his articles may be found at his website or the blog. He lives in Plainsboro, NJ, USA and may be reached at jkrishnaswamy@comcast.net Books from Packt
|
In this article by Dr. Jayaram Krishnaswamy, we will learn about migration of data from MS SQL Server 2008 to EnterpriseDB. Migration Studio bundled with the EnterpriseDB download is a collection of tools to migrate automatically the data and business logic into Postgres from a variety of vendor products that include SQL Server, Oracle, MySQL to mention a few. This article shows you step by step how you may migrate a SQL Server 2008 table to Postgres Plus. You can only migrate tables and schemas but not database as a whole. See More |
| ||||||||