Discussion:
connecting to informix
(too old to reply)
vindictive27
2008-11-14 19:51:35 UTC
Permalink
I am trying to connect to Informix using an existing application with
a field for a connection string. Using the ODBC driver works great,
however I would like to use the .NET driver for performance reasons.
Is there a way to specify the string use that driver instead of the
current example:

Driver={IBM INFORMIX ODBC
DRIVER};Server=svr_custom;Database=test;Uid=username;Pwd=password

I would like to make it use the .NET driver instead. Any suggestions?

This is an application that listens to messages from a socket message
handler and then processes them for use in the database.
Sheshnarayan Agrawal
2008-11-15 05:54:47 UTC
Permalink
I am presuming you have VB/C# application whereas you are trying to use
both ODBC and .NET providers. Below is simple snippet of code which can be
used for ODBC/.NET and also for OLEDB providers in C# environment.

If you could share your performance results would be helpful.

using System;
using System.Data;
using IBM.Data.Informix;
using System.Data.OleDb;
using System.Data.Odbc;

class TestClass
{
static void Main(string[] args)
{

IDbConnection conn = null;
int rows = 0;
String value = "";

if (args[0] == "NET")
conn = new IfxConnection("Server=ol_shesh_ids1150;User
ID=informix;password=xxx;Database=sysmaster;");

if (args[0] == "ODBC")
conn = new OdbcConnection("Driver={IBM INFORMIX ODBC
DRIVER};UID=informix;PWD=xxx;DATABASE=sysmaster;SERVER=ol_shesh_ids1150;"
);

if (args[0] == "OLEDB")
conn = new OleDbConnection("Provider=Ifxoledbc;Data
Source=***@ol_shesh_ids1150;User ID=informix;Password=xxx;");

conn.Open();
IDbCommand Selcmd = conn.CreateCommand();
Selcmd.CommandText = "select tabname from systables where tabid<5";
Selcmd.CommandType = CommandType.Text;
Selcmd.Connection = conn;
IDataReader DReader = Selcmd.ExecuteReader();
while (DReader.Read())
{
rows++;
value = DReader[0].ToString();
Console.WriteLine("Value: " + value);
}

Console.WriteLine("Number of Rows Retrieved: " + rows);
DReader.Close();
conn.Close();
conn.Dispose();
}
else
Console.WriteLine("common_test.exe [ODBC/OLEDB/NET]");
}
}

HTH..
-Shesh




vindictive27 <***@gmail.com>
Sent by: informix-list-***@iiug.org
15/11/2008 01:21

To
informix-***@iiug.org
cc

Subject
connecting to informix






I am trying to connect to Informix using an existing application with
a field for a connection string. Using the ODBC driver works great,
however I would like to use the .NET driver for performance reasons.
Is there a way to specify the string use that driver instead of the
current example:

Driver={IBM INFORMIX ODBC
DRIVER};Server=svr_custom;Database=test;Uid=username;Pwd=password

I would like to make it use the .NET driver instead. Any suggestions?

This is an application that listens to messages from a socket message
handler and then processes them for use in the database.
brenddie
2008-11-16 00:14:11 UTC
Permalink
from a web.config file I use:

<add key="Conn1" value="database=db1; HOST=192.168.0.1;
server=db_engine_tcp; service=1492; protocol=onsoctcp; UID=informix;
password=passwd;DELIMIDENT=n;Pooling=False;" />


and some sample/test code:

Dim myConnectionString As New String
(System.Configuration.ConfigurationManager.AppSettings("Conn1"))
Dim myConnection As New IBM.Data.Informix.IfxConnection
(myConnectionString)

myConnection.Open()

Dim SqlQuery As String

SqlQuery = "select * from a1 "

Dim myCommand As New IBM.Data.Informix.IfxCommand(SqlQuery,
myConnection)
myCommand.CommandTimeout = 0

Dim myDataAdapter As IBM.Data.Informix.IfxDataAdapter

myDataAdapter = New IBM.Data.Informix.IfxDataAdapter(SqlQuery,
myConnection)
myDataAdapter.SelectCommand = myCommand
myDataAdapter.SelectCommand.CommandTimeout = 0

Try
myDataAdapter.Fill(myDS, "test")
'Me.GridView1.DataSource = myDS.Tables("test")
'Me.GridView1.DataBind()

Catch ex As Exception
Response.Write("Error: " & ex.Message)
Finally
myCommand.Dispose()
myDataAdapter.Dispose()
myConnection.Dispose()
End Try

Continue reading on narkive:
Loading...