Click here to Skip to main content
15,922,584 members
Home / Discussions / C#
   

C#

 
GeneralRe: SqlTransaction object Pin
Vipin.d11-Nov-07 20:25
Vipin.d11-Nov-07 20:25 
GeneralRe: SqlTransaction object Pin
Adeel Chaudhry11-Nov-07 20:25
Adeel Chaudhry11-Nov-07 20:25 
GeneralRe: SqlTransaction object Pin
Vipin.d11-Nov-07 20:26
Vipin.d11-Nov-07 20:26 
GeneralRe: SqlTransaction object Pin
Adeel Chaudhry11-Nov-07 20:38
Adeel Chaudhry11-Nov-07 20:38 
GeneralRe: SqlTransaction object Pin
Vipin.d11-Nov-07 20:42
Vipin.d11-Nov-07 20:42 
AnswerRe: SqlTransaction object Pin
Andrei Ungureanu11-Nov-07 20:14
Andrei Ungureanu11-Nov-07 20:14 
GeneralRe: SqlTransaction object Pin
Vipin.d11-Nov-07 20:23
Vipin.d11-Nov-07 20:23 
GeneralRe: SqlTransaction object Pin
Andrei Ungureanu11-Nov-07 20:43
Andrei Ungureanu11-Nov-07 20:43 
The ConnectionString property can be set only when the connection is closed. (from MSDN) and when you close a query, the pending transactions are rolledback.
So...my suggestion is to use at least 2 connections
using (SqlConnection conn = new SqlConnection())
{
 //set the first cs
 string cs1 = "connection string 1";
 conn.ConnectionString = cs1;

 conn.Open();

 SqlTransaction trans = conn.BeginTransaction();

 //do the the select query

 if (InsertSecondDB())
 {
  //update first DB
  trans.Commit();
 }
 else
 {
  trans.Rollback();
 }

 conn.Close();
}


The InsertSecondDB should create a new connection and a new transaction to the second DataBase and return true if the query succeeded or false otherwise.

Hope it helps.

I will use Google before asking dumb questions

GeneralRe: SqlTransaction object Pin
Vipin.d11-Nov-07 20:46
Vipin.d11-Nov-07 20:46 
AnswerRe: SqlTransaction object Pin
Vipin.d11-Nov-07 20:55
Vipin.d11-Nov-07 20:55 
Questionfile synchronisation in c# Pin
suny12311-Nov-07 19:21
suny12311-Nov-07 19:21 
AnswerRe: file synchronisation in c# Pin
Adeel Chaudhry11-Nov-07 20:01
Adeel Chaudhry11-Nov-07 20:01 
AnswerRe: Please can any one help me in customizing the open file dialog selection Pin
Adeel Chaudhry11-Nov-07 19:02
Adeel Chaudhry11-Nov-07 19:02 
AnswerRe: Please can any one help me in customizing the open file dialog selection Pin
Please can any one help me in customizing the open11-Nov-07 21:11
Please can any one help me in customizing the open11-Nov-07 21:11 
QuestionHow to find the encoding of a file? Pin
deep_C#11-Nov-07 18:47
deep_C#11-Nov-07 18:47 
AnswerRe: How to find the encoding of a file? Pin
Adeel Chaudhry11-Nov-07 19:05
Adeel Chaudhry11-Nov-07 19:05 
QuestionHow can we retrive particular column data from Dataset? Pin
pekhaleyogesh11-Nov-07 18:43
pekhaleyogesh11-Nov-07 18:43 
AnswerRe: How can we retrive particular column data from Dataset? Pin
Pankaj - Joshi11-Nov-07 18:55
Pankaj - Joshi11-Nov-07 18:55 
GeneralRe: How can we retrive particular column data from Dataset? Pin
pekhaleyogesh11-Nov-07 19:00
pekhaleyogesh11-Nov-07 19:00 
QuestionPlease can any one help me in customizing the open file dialog selection Pin
Please can any one help me in customizing the open11-Nov-07 18:35
Please can any one help me in customizing the open11-Nov-07 18:35 
QuestionRegarding, creating the table in MSWord Document from C#.Net. Pin
Ron.S11-Nov-07 18:34
Ron.S11-Nov-07 18:34 
QuestionHow to get Server Application path. Pin
clife53711-Nov-07 18:21
clife53711-Nov-07 18:21 
AnswerRe: How to get Server Application path. Pin
Vasudevan Deepak Kumar11-Nov-07 18:23
Vasudevan Deepak Kumar11-Nov-07 18:23 
AnswerRe: How to get Server Application path. Pin
clife53711-Nov-07 19:13
clife53711-Nov-07 19:13 
QuestionC# developer Pin
super flower11-Nov-07 18:18
super flower11-Nov-07 18:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.