Save 
Join IIUG
 for   
 

Informix News
9 Apr 12 - Mastering Data Management - Upping the Informix Ante: Advanced Data Tools... Read
22 Mar 12 - developerWorks - Optimizing Informix database access... Read
14 Mar 12 - BernieSpang.com - International Informix User Group set to meet in San Diego... Read
1 Mar 12 - IBM Data Management - IIUG Heads West for 2012 - Get ready for sun and sand in San Diego... Read
1 Mar 12 - IBM Data Management - Running Informix on Solid-State Drives.Speed Up Database Access... Read
26 Feb 12 - BernieSpan.com - Better results, lower cost for a broad set of new IBM clients and partners... Read
24 Feb 12 - developerWorks - Informix Warehouse Accelerator: Continuous Acceleration during Data Refresh... Read
6 Feb 12 - PRLOG - Informix port delivers unlimited database scalability for popular SaaS application ... Read
2 Feb 12 - developerWorks - Loading data with the IBM Informix TimeSeries Plug-in for Data Studio... Read
1 Feb 12 - developerWorks - 100 Tech Tips, #47: Log-in to Fix Central... Read
13 Jan 12 - MC Press online - Informix Dynamic Server Entices New Users with Free Production Edition ... Read
11 Jan 12 - Computerworld - Ecologic Analytics and Landis+Gyr -- Suitors Decide to Tie the Knot... Read
9 Jan 12 - planetIDS.com - DNS impact on Informix / Impacto do DNS no Informix... Read
8 Sep 11 - TMCnet.com - IBM Offers Database Solution to Enable Smart Meter Data Capture... Read
1 Aug 11 - IBM Data Management Magazine - IIUG user view: Happy 10th anniversary to IBM and Informix... Read
8 Jul 11 - Database Trends and Applications - Managing Time Series Data with Informix... Read
31 May 11 - Smart Grid - The meter data management pitfall utilities are overlooking... Read
27 May 11 - IBM Data Management Magazine - IIUG user view: Big data, big time ( Series data, warehouse acceleration, and 4GLs )... Read
16 May 11 - Business Wire - HiT Software Announces DBMoto for Enterprise Integration, Adds Informix. Log-based Change Data Capture... Read
21 Mar 11 - Yahoo! Finance - IBM and Cable&Wireless Worldwide Announce UK Smart Energy Cloud... Read
14 Mar 11 - MarketWatch - Fuzzy Logix and IBM Unveil In-Database Analytics for IBM Informix... Read
11 Mar 11 - InvestorPlace - It's Time to Give IBM Props: How many tech stocks are up 53% since the dot-com boom?... Read
9 Mar 11 - DBTA - Database Administration and the Goal of Diminishing Downtime... Read
2 Feb 11 - DBTAs - Informix 11.7 Flexible Grid Provides a Different Way of Looking at Database Servers... Read
27 Jan 11 - exactsolutions - Exact to Add Informix Support to Database Replay, SQL Monitoring Solutions... Read
25 Jan 11 - PR Newswire - Bank of China in the UK Works With IBM to Become a Smarter, Greener Bank... Read
12 Oct 10 - Database Trends and Applications - Informix 11.7: The Beginning of the Next Decade of IBM Informix... Read
20 Sep 10 - planetIDS.com - ITG analyst paper: Cost/Benefit case for IBM Informix as compared to Microsoft SQL Server... Read
20 Jul 10 - IBM Announcements - IBM Informix Choice Edition V11.50 helps deploy low-cost scalable and reliable solutions for Apple Macintosh and Microsoft Windows... Read
20 Jul 10 - IBM Announcements - Software withdrawal: Elite Support for Informix Ultimate-C Edition... Read
24 May 10 - eWeek Europe - IBM Supplies Database Tech For EU Smart Grid... Read
23 May 10 - SiliconIndia - IBM's smart metering system allows wise use of energy... Read
21 May 10 - CNET - IBM to help people monitor energy use... Read
20 May 10 - ebiz - IBM Teams With Hildebrand To Bring Smart Metering To Homes Across Britain... Read
19 May 10 - The New Blog Times - Misurare il consumo energetico: DEHEMS è pronto... Read
19 May 10 - ZDNet - IBM software in your home? Pact enables five-city smart meter pilot in Europe... Read
17 March 10 - ZDNet (blog) David Morgenstern - TCO: New research finds Macs in the enterprise easier, cheaper to manage than... Read
17 March 2010 - Virtualization Review - ...key components of Big Blue's platform to the commercial cloud such as its WebSphere suite of application ser vers and its DB2 and Informix databases... Read
10 February 2010 - The Wall Street Journal - International Business Machines is expanding an initiative to win over students and professors on its products. How do they lure the college crowd?... Read


End of Support Dates

IIUG on Facebook IIUG on Twitter


[ Post Response ] [ Return to Index ] [ Read Prev Msg ] [ Read Next Msg ]

Classics Forum

Informix, ODBC, ADO and VB

Posted By: KEVIN GODSMAN
Date: Tuesday, 21 October 2003, at 7:40 a.m.

Hello.

Some time ago I posted a question on this board about Informix, ODBC,
ADO and VB. I managed to solve my connection problems and wrote a VB
program to do an ADO based ODBC connection. I've been using this
program successfully for about six months.

Since then quite a few people have sent me email asking me how to do
the connection. Unfortunately I haven't got time to answer these emails
and I really don't have time to get into discussions re setup problems,
error messages and connection difficulties.

However in the interests of knowledge distribution, please find enclosed
a VB program, which should answer most of your questions. It has the
following attributes ...

1. It assumes you've taken care of the Unix Informix database naming.
(See section A)

2. It assumes you've taken care of the basic Windows ODBC setup.
(See Section B)

3. It uses ADO to create an ODBC connection to an Informix database.

4. I'm using it with Informix 7.3 but it should work on all versions.

5. It uses Informix Connect and Data Direct 4.1 Informix ODBC Driver.

6. It assumes your VB application is referencing Microsoft Active X
Data Objects 2.7 Library.

7. The code will work in VB Script, VB and VB.net as long as you do
the relevant tweeks for the relevant language.

8. If you can't work out from the VB code what forms, text boxes and
buttons you need, then I suggest you purchase a guide to VB
programming.

9. When I wrote the code it was beautifully and correctly indented.
It doesn't appear that way in the preview message area, so may
no look that way in the actual message area ... if so you'll
just have to indent it yourself!

Cheers

Kevin Godsman


--------------------------------------------------------------------------

Section A: Unix Database Naming

1. Ensure DBServerName and DBServerAliase are set in the
System Configuration section of your Informix onconfig file.

eg live_soc for a live database server / database server alias
... used as an example in Section B

--------------------------------------------------------------------------

Section B: Basic Windows ODBC Setup

1. Load Informix Connect to c:\informix on your Windows PC

2. Load Data Direct Informix 4.1 ODBC Driver on your Windows PC

3. Run Informix Setnet32

Set Environment/InformixDir to c:\informix
Set Environment/DBDate to DMY4 for UK format and MDY4 for US format
Set up a Server, eg live_soc

4. Create hosts, sqlhosts, services and onconfig files:

# Hosts File
# Columns are IP Address / Host Name

n.n.n.n informix_machine_name

# SQL Hosts File
# Columns are SQL Host Name / Protocol Name / Host Name / Service
# Host Name must be in Onconfig File
# Service links to service in Services File

live_soc onsoctcp informix_machine_name livesoc

# Services File
# Columns are Service / TCPIP Port Number
# Service is taken from SQL Hosts File

livesoc n/tcp

# On Config File
# Columns are DBSERVERNAME and Database Server Name
# Database Server Name is taken from SQL Hosts File

DBSERVERNAME live_soc

Copy these files to:

c:\informix\etc
c:\windows\system32\drivers\etc

5. Test the connection using Microsoft ODBC Administrator

If the ODBC connection fails check that you can ping your server,
that you created the files correctly and that you copied the files
to the correct directories.


--------------------------------------------------------------------------

Section B: Visual Basic Program


Public db As ADODB.Connection

' ADO database connection
' nb Would usually be put in a global module so the
' connection can be used throughout the application


Private Sub FormLoad()

' Populate connection setting text boxes
' nb The host, server, service and database values will
' be specific to your own Informix configuration

TBDriver.Text = "DataDirect 4.1 Informix"
TBHost.Text = "host"
TBServer.Text = "server"
TBService.Text = "service"
TBProtocol.Text = "onsoctcp"
TBDatabase.Text = "database"
TBUserName.Text = ""
TBPassword.PasswordChar = "*"
TBPassword.Text = ""
Me.Show
TBUserName.SetFocus

End Sub



Private Sub BTConnectToInformix_Click()

Dim msg As String ' Message
Dim style As Integer ' Message style
Dim title As String ' Message title
Dim dbdriver As String ' ODBC driver
Dim dbhost As String ' Host name
Dim dbserver As String ' Informix server
Dim dbservice As String ' Database service name
Dim dbprotocol As String ' Database protocol
Dim dbdatabase As String ' Database name
Dim dbusername As String ' Database user name
Dim dbpassword As String ' Database password
Dim dbconnection As String ' Database connection
Dim faultcount As Integer ' Number of ADO fault

On Error GoTo ErrorHandler

Screen.MousePointer = vbHourglass

' Ensure data has been entered

If TBDriver.Text = "" _
Or TBHost.Text = "" _
Or TBServer.Text = "" _
Or TBService.Text = "" _
Or TBProtocol.Text = "" _
Or TBDatabase.Text = "" _
Or TBUserName.Text = "" _
Or TBPassword.Text = "" Then
title = "Error"
style = vbOKOnly & vbCritical
msg = "Please enter all connection settings"
MsgBox msg, style, title
Screen.MousePointer = vbNormal
TBUserName.SetFocus
Exit Sub
End If

' Create database connection string

dbdriver = "DRIVER=" & TBDriver.Text & ";"
dbhost = "HOST=" & TBHost.Text & ";"
dbserver = "SRVR=" & TBServer.Text & ";"
dbservice = "SERV=" & TBService.Text & ";"
dbprotocol = "PRO=" & TBProtocol.Text & ";"
dbdatabase = "DB=" & TBDatabase.Text & ";"
dbusername = "UID=" & TBUserName.Text & ";"
dbpassword = "PWD=" & TBPassword.Text & ";"
dbconnection = dbdriver & dbusername & dbpassword & dbprotocol & dbserver & dbservice & dbhost & dbdatabase

' Configure database connection

Set db = New ADODB.Connection
db.Provider = "MSDASQL"
db.ConnectionTimeout = 30
db.ConnectionString = dbconnection
db.CursorLocation = adUseServer
'db.CursorLocation = adUseClient
db.IsolationLevel = adXactCursorStability
db.CommandTimeout = 60

' Open database connection

db.Open

' Display main screen

Screen.MousePointer = vbNormal
Unload Me
Load FormMain
FormMain.Show

Exit Sub

ErrorHandler:

' Covers standard VB errors and ADO database problems

title = "Error"
style = vbOKOnly + vbCritical
msg = "VB Error Number: " & Err & vbCr
msg = msg & "VB Description: " & Error & vbCr
If db.Errors.count > 0 Then
For faultcount = 0 To db.Errors.count - 1
msg = msg & vbCr
msg = msg & "VB Error Number: " & db.Errors(faultcount).Number & vbCr
msg = msg & "ADO Error Number: " & db.Errors(faultcount).NativeError & vbCr
msg = msg & "ADO Source: " & db.Errors(faultcount).Source & vbCr
msg = msg & "ADO Description: " & db.Errors(faultcount).Description & vbCr
Next faultcount
db.Errors.Clear
End If
MsgBox msg, style, title
Exit Sub

End Sub

[ Post Response ] [ Return to Index ] [ Read Prev Msg ] [ Read Next Msg ]

Classics Forum is maintained by Administrator with WebBBS 5.12.