Hi,
I want to make transactional a series of sp call (sql server 2005) in a .net 2.0 project surrounding some piece of business logic with a
using(TransactionScope...)
Unluckily, I inherited the DAL from another project and I don't want to make many changes there..the problem is that every method that calls a stored procedure opens a new connection.
So, my question is: is there a way to retrieve the connection used by current transaction i.e. from Transaction.Current??
Thank you
s.
UPDATE: Please tell me what it's wrong with this console application (vs2005, .net 2.0, Sql server 2005)
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.Transactions;
namespace ConsoleApplication1
{
public class Program
{
static void Main(string[] args)
{
using (TransactionScope ts = new TransactionScope(TransactionScopeOption.Required))
{
Console.WriteLine("1");
test();
Console.WriteLine("2");
test();
}
Console.WriteLine("END");
}
public static void test()
{
string connectionString = @"Persist Security Info=True;User ID=usr123;Password=123;Initial Catalog=db123;Data Source=myserver\myinstance;Connect Timeout=180;";
using (SqlConnection conn = new SqlConnection(connectionString))
{
conn.Open();
}
}
}
}