Hi all,
I've been trying to get a distributed transaction working between a
..Net client and DB2/UDB. I've tried the following combinations:
Client Server
Win 2000 SP4 DB2/UDB Ver 8.2 AIX server
Win 2000 SP4 DB2/UDB Ver 8.2 Win 2000 Server SP4
Win XP SP2 DB2/UDB Ver 8.2 AIX server
Win XP SP2 DB2/UDB Ver 8.2 Win 2000 Server SP4
All with .Net Framework 1.1. I've also tried patching the .Net
framework with SP1.
The code falls over during the connection with the following message:
ERROR [42705] [IBM] SQL1013N The database alias name or database name
"" could not be found. SQLSTATE=42705
When TransactionOption.Supported is used, everything works fine.
The code is below. I've omitted the basic IDB2Tester interface and the
console app code that runs the test.
using System;
using System.Data;
using System.EnterpriseServices;
using System.Runtime.InteropServices;
using IBM.Data.DB2;
namespace Db2ComPlusComponent
{
[ Transaction( TransactionOption.Required ) ]
[ ClassInterface( ClassInterfaceType.None ) ]
[ Guid( "3CBFC57F-9035-4851-8E47-CC26E13D9F53" ) ]
public class DB2Tester : ServicedComponent, IDB2Tester
{
private string _connectionString =
"server=THE-SERVER:50000;database=SAMPLE;user
Id=db2admin;pwd=thepassword";
public DB2Tester()
{
}
public int ProcessResultSet()
{
DB2Connection conn = new DB2Connection(
_connectionString );
DB2Command cmd = new DB2Command(
"Select * from administrator.employee" );
cmd.Connection = conn;
int rowCount = -1;
try
{
conn.Open();
DataSet ds = new DataSet();
using ( DB2DataAdapter da = new DB2DataAdapter( cmd ) )
{
da.Fill( ds );
}
rowCount = ds.Tables[ 0 ].Rows.Count;
}
catch ( DB2Exception e )
{
Console.Write( "Not working ... {0}{1}",
Environment.NewLine, e.Message );
}
finally
{
conn.Dispose();
}
return rowCount;
}
}
}
Thanks in advance,
Christian Maslen