dbaspot
Tags Register FAQ Calendar Search Today's Posts Mark Forums Read

Re: connecting to informix - informix

This is a discussion on Re: connecting to informix - informix ; 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 ...


Home > Database Forum > Other Databases > informix > Re: connecting to informix

Reply

 

LinkBack Thread Tools Display Modes
  #1  
Old 11-15-2008, 01:54 AM
Database Bot
 
Join Date: Sep 2009
Posts: 1,236,254
Database Administrator is on a distinguished road
Default Re: connecting to informix

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;SE RVER=ol_shesh_ids1150;"
);

if (args[0] == "OLEDB")
conn = new OleDbConnection("Provider=Ifxoledbc;Data
Source=sysmaster@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
Sent by: informix-list-bounces@iiug.org
15/11/2008 01:21

To
informix-list@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=userna me;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.
_______________________________________________
Informix-list mailing list
Informix-list@iiug.org
http://www.iiug.org/mailman/listinfo/informix-list


Reply With Quote
Reply

Thread Tools
Display Modes



All times are GMT -4. The time now is 09:49 AM.