By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,514 Members | 1,702 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,514 IT Pros & Developers. It's quick & easy.

MS-DTC and .Net client doesn't work with Transaction Required

P: n/a
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

Nov 12 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
How have you configured DB2 for MS DTC? From the error message, I get the
feeling you're using DB2 transaction coordination, but without creating, or
at leasting configuring the transaction database.

"Christian Maslen" <ch**************@techie.com> wrote in message
news:11**********************@g43g2000cwa.googlegr oups.com...
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

Nov 12 '05 #2

P: n/a
Mark

Thanks for your response - I'm working with Christian on this issue.
On the server running MS DTC we have the DB2 client configured with
TP_DATABASE="1ST_CONN" and TP_MON_NAME is blank (as per IBM's
documentation for using MTS).

Is there anything else that we need to configure? Do we need to
request specific server side configuration from our DBAs to support
distributed transactions?

Regards
Alistair

Nov 12 '05 #3

P: n/a
<al*****************@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
Mark

Thanks for your response - I'm working with Christian on this issue.
On the server running MS DTC we have the DB2 client configured with
TP_DATABASE="1ST_CONN" and TP_MON_NAME is blank (as per IBM's
documentation for using MTS).

Is there anything else that we need to configure?
YES. You have to install your code into a COM+ package (or its .NET
equivalent) that is configured for transactions. [MTS is the name under NT4
+ Options Pack, from W2K on, it's called COM+].

The option is called TM_DATABASE, and if you intend to use one, you should
create it and configure it. 1ST_CONN is a lousy default. You would also need
to create and configure your syncpoint manager (SPM_*). The control centre
has a GUI interface for most of this.
Do we need to request specific server side configuration from our DBAs
to support distributed transactions?
YES. You need to enable two phase commit. I strongly recommend your asking
your DBA for assistance.

Regards
Alistair

Nov 12 '05 #4

P: n/a
Sorry about the late reply...
YES. You have to install your code into a COM+ package (or its .NET
equivalent) that is configured for transactions. [MTS is the name under
NT4
+ Options Pack, from W2K on, it's called COM+].
<<

Did this.
The option is called TM_DATABASE, and if you intend to use one, you
should
create it and configure it. 1ST_CONN is a lousy default. You would also
need
to create and configure your syncpoint manager (SPM_*). The control
centre
has a GUI interface for most of this.
<<

This has also been setup. We (the DBA and I) tried TM_DATABASE with a
specific database and 1ST_CONN. When you say create and configure the
syncpoint manager, what do you mean by this? The SPM_NAME has been set
for the instance, and I can't find any DB2 doco that mentions what else
apart from putting in a name is required.

YES. You need to enable two phase commit. I strongly recommend your
asking
your DBA for assistance.
<<

My DBA assures me this has been done.

Regards,
Christian Maslen

Nov 12 '05 #5

P: n/a
SPM_NAME, TM_DATABASE and 1ST_CONN are for DB2-controlled transaction
management. You say you've set these up.

Your question concerned using .NET (COM+) to control the transactions. You
say you've installed your code into COM+.

I suspect that your problems are caused by your confusing these two. You
have to decide what you want, and configure for that.

"Christian Maslen" <ch**************@techie.com> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
Sorry about the late reply...
YES. You have to install your code into a COM+ package (or its .NET
equivalent) that is configured for transactions. [MTS is the name under
NT4
+ Options Pack, from W2K on, it's called COM+].
<<

Did this.
The option is called TM_DATABASE, and if you intend to use one, you
should
create it and configure it. 1ST_CONN is a lousy default. You would also
need
to create and configure your syncpoint manager (SPM_*). The control
centre
has a GUI interface for most of this.
<<

This has also been setup. We (the DBA and I) tried TM_DATABASE with a
specific database and 1ST_CONN. When you say create and configure the
syncpoint manager, what do you mean by this? The SPM_NAME has been set
for the instance, and I can't find any DB2 doco that mentions what else
apart from putting in a name is required.

YES. You need to enable two phase commit. I strongly recommend your
asking
your DBA for assistance.
<<

My DBA assures me this has been done.

Regards,
Christian Maslen

Nov 12 '05 #6

P: n/a
Hi all,

I've been trying to get a distributed transaction working between a
.Net client and DB2/UDB....


The problem has been fixed. The issue was with the connection string
specifying the server name and port. So instead of:

_ConnnectionString = "server=THE-SERVER:50000;datab*ase=SAMPLE;user
Id=db2admin;pwd=thepassword";

use:
_ConnnectionString =
"datab*ase=SAMPLE;userId=db2admin;pwd=thepassword" ;

I found this by running the LCTrans sample that is installed with the
developer client (I should have tried this first ;o). If anyone knows
why this fix works that would be handy.

Mark,

Thanks again for your help on this.

Christian Maslen

Nov 12 '05 #7

P: n/a
Yes, forcing the connection's server is a demand for an external transaction
manager *not* to be used, as it bypasses the COM+ facilities.

"Christian Maslen" <ch**************@techie.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
Hi all,

I've been trying to get a distributed transaction working between a
.Net client and DB2/UDB....


The problem has been fixed. The issue was with the connection string
specifying the server name and port. So instead of:

_ConnnectionString = "server=THE-SERVER:50000;datab*ase=SAMPLE;user
Id=db2admin;pwd=thepassword";

use:
_ConnnectionString =
"datab*ase=SAMPLE;userId=db2admin;pwd=thepassword" ;

I found this by running the LCTrans sample that is installed with the
developer client (I should have tried this first ;o). If anyone knows
why this fix works that would be handy.

Mark,

Thanks again for your help on this.

Christian Maslen
Nov 12 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.