Click here to Skip to main content
15,918,168 members
Home / Discussions / Database
   

Database

 
AnswerRe: How can I specify temp table as Source/Destination table for DTS "Transform Data Task"? Pin
Frank Kerrigan14-Dec-06 23:51
Frank Kerrigan14-Dec-06 23:51 
GeneralURGENT Re: How can I specify temp table as Source/Destination table for DTS "Transform Data Task"? Pin
devvvy17-Dec-06 17:09
devvvy17-Dec-06 17:09 
QuestionExporting and Import DTS packages? Pin
devvvy14-Dec-06 21:08
devvvy14-Dec-06 21:08 
AnswerRe: Exporting and Import DTS packages? Pin
Frank Kerrigan14-Dec-06 23:48
Frank Kerrigan14-Dec-06 23:48 
GeneralRe: Exporting and Import DTS packages? Pin
devvvy16-Dec-06 15:37
devvvy16-Dec-06 15:37 
QuestionCursor and set , execute Statement related Query Pin
param thaker14-Dec-06 19:47
param thaker14-Dec-06 19:47 
AnswerRe: Cursor and set , execute Statement related Query Pin
Frank Kerrigan14-Dec-06 23:54
Frank Kerrigan14-Dec-06 23:54 
QuestionOpening and Closing Conneciton for a loop Pin
Amrish Deep14-Dec-06 17:05
Amrish Deep14-Dec-06 17:05 
Hi ,
I am using the System.Data.Common.DBCommand to insert values into a table in a loop with each loop generating a SQL statement and inserting values into the table. The scenario is something like this.

foreach loop
{
DBCommand db = db.GetSqlStringCommand(loop generated string);
db.Connection = db.DbProviderFactory.CreateConnection();
db.Connection.ConnectionString = db.ConnectionStringWithoutCredentials;

db.Connection.Open();
db.ExecuteNonQuery();
db.Connection.Open();

}

the question is that should i open and close the connection everytime? if i dont open the connection in the loop and if i try something like this

DBCommand db = null;
db.Connection = db.DbProviderFactory.CreateConnection();
db.Connection.ConnectionString = db.ConnectionStringWithoutCredentials;
db.connection.open();

foreach loop
{
DBCommand db = db.GetSqlStringCommand(loop generated string);
db.Connection = db.DbProviderFactory.CreateConnection();
db.Connection.ConnectionString = db.ConnectionStringWithoutCredentials;
db.ExecuteNonQuery();

}

Then it throws an error telling that a connection does not exist. Is there anyother way to open the connection just once?


--Amrish

AnswerRe: Opening and Closing Conneciton for a loop Pin
Paul Conrad14-Dec-06 18:12
professionalPaul Conrad14-Dec-06 18:12 
AnswerRe: Opening and Closing Conneciton for a loop Pin
coolestCoder14-Dec-06 19:01
coolestCoder14-Dec-06 19:01 
QuestionAdding a new row Pin
goldoche14-Dec-06 5:59
goldoche14-Dec-06 5:59 
AnswerRe: Adding a new row Pin
Karma3125114-Dec-06 10:12
Karma3125114-Dec-06 10:12 
Questionhi Pin
Tauseef A14-Dec-06 1:01
Tauseef A14-Dec-06 1:01 
AnswerRe: hi Pin
Colin Angus Mackay14-Dec-06 1:43
Colin Angus Mackay14-Dec-06 1:43 
AnswerRe: hi Pin
Frank Kerrigan14-Dec-06 3:30
Frank Kerrigan14-Dec-06 3:30 
GeneralRe: hi Pin
Tauseef A14-Dec-06 9:37
Tauseef A14-Dec-06 9:37 
GeneralRe: hi Pin
Colin Angus Mackay14-Dec-06 13:31
Colin Angus Mackay14-Dec-06 13:31 
QuestionRe: hi Pin
Tauseef A14-Dec-06 19:35
Tauseef A14-Dec-06 19:35 
AnswerRe: hi Pin
Frank Kerrigan14-Dec-06 23:55
Frank Kerrigan14-Dec-06 23:55 
GeneralRe: hi Pin
Tauseef A15-Dec-06 6:31
Tauseef A15-Dec-06 6:31 
GeneralRe: hi Pin
Private_Void15-Dec-06 7:19
Private_Void15-Dec-06 7:19 
AnswerRe: hi Pin
S Douglas17-Dec-06 23:20
professionalS Douglas17-Dec-06 23:20 
QuestionExtended SP (CLRSP) in .net Pin
om474113-Dec-06 23:39
om474113-Dec-06 23:39 
QuestionRestoring a database problem - database in use Pin
steve_rm13-Dec-06 15:50
steve_rm13-Dec-06 15:50 
AnswerRe: Restoring a database problem - database in use Pin
Andy Brummer13-Dec-06 17:39
sitebuilderAndy Brummer13-Dec-06 17:39 

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.