Click here to Skip to main content
15,886,724 members
Home / Discussions / C#
   

C#

 
GeneralRe: update Dictionary with new KeyValuePair set Pin
PIEBALDconsult27-Mar-10 17:23
mvePIEBALDconsult27-Mar-10 17:23 
QuestionHow can i know from which interface the method is calling? Pin
Satish - Developer27-Mar-10 2:46
Satish - Developer27-Mar-10 2:46 
AnswerRe: How can i know from which interface the method is calling? Pin
Nuri Ismail27-Mar-10 3:03
Nuri Ismail27-Mar-10 3:03 
AnswerRe: How can i know from which interface the method is calling? Pin
AspDotNetDev27-Mar-10 3:13
protectorAspDotNetDev27-Mar-10 3:13 
QuestionHow to write the design editor? Pin
yu-jian27-Mar-10 1:34
yu-jian27-Mar-10 1:34 
AnswerRe: How to write the design editor? Pin
yu-jian28-Mar-10 3:34
yu-jian28-Mar-10 3:34 
GeneralRe: How to write the design editor? Pin
OriginalGriff28-Mar-10 4:10
mveOriginalGriff28-Mar-10 4:10 
QuestionA question on SqlCommand.CommandText Pin
Dewald26-Mar-10 23:01
Dewald26-Mar-10 23:01 
Hi all,

In my application I'd like to write the command that was executed against a SQL database to a log file.

I can't just write the SqlCommand.CommandText property as that might look something like:
"INSERT INTO Users (UserName, Address, PhoneNo) VALUES (@UserName, @Address, @PhoneNo)"

which obviously is of no use to log. The values of the parameters has to be logged as well. I'd prefer not to have to make additional log entries for every parameter so what I've done now is something like this:
string CmdTxt = mySqlCommand.CommandText;
foreach (SqlParameter parm in mySqlCommand.Parameters)
{
   CmdTxt = CmdTxt.Replace(parm.ParameterName, "'" + parm.Value.ToString().Replace("'", "''") + "'");
}

And then write CmdTxt to the log.

Does anyone know of a more elegant way of doing this? Is there not perhaps a different member of SqlCommand that I could use?
AnswerRe: A question on SqlCommand.CommandText [modified] Pin
Dan Mos27-Mar-10 0:24
Dan Mos27-Mar-10 0:24 
AnswerRe: A question on SqlCommand.CommandText Pin
#realJSOP27-Mar-10 1:29
mve#realJSOP27-Mar-10 1:29 
AnswerRe: A question on SqlCommand.CommandText Pin
PIEBALDconsult27-Mar-10 4:28
mvePIEBALDconsult27-Mar-10 4:28 
QuestionCompress a Folder using GZipStream Pin
anishkannan26-Mar-10 21:57
anishkannan26-Mar-10 21:57 
AnswerRe: Compress a Folder using GZipStream Pin
Richard MacCutchan26-Mar-10 23:05
mveRichard MacCutchan26-Mar-10 23:05 
GeneralRe: Compress a Folder using GZipStream Pin
AspDotNetDev26-Mar-10 23:23
protectorAspDotNetDev26-Mar-10 23:23 
GeneralRe: Compress a Folder using GZipStream Pin
Richard MacCutchan26-Mar-10 23:44
mveRichard MacCutchan26-Mar-10 23:44 
GeneralRe: Compress a Folder using GZipStream Pin
AspDotNetDev26-Mar-10 23:53
protectorAspDotNetDev26-Mar-10 23:53 
GeneralRe: Compress a Folder using GZipStream Pin
Richard MacCutchan27-Mar-10 3:19
mveRichard MacCutchan27-Mar-10 3:19 
GeneralRe: Compress a Folder using GZipStream Pin
AspDotNetDev27-Mar-10 3:27
protectorAspDotNetDev27-Mar-10 3:27 
GeneralRe: Compress a Folder using GZipStream Pin
Richard MacCutchan27-Mar-10 3:46
mveRichard MacCutchan27-Mar-10 3:46 
QuestionCompress a Folder Pin
anishkannan26-Mar-10 21:56
anishkannan26-Mar-10 21:56 
AnswerRe: Compress a Folder Pin
R. Giskard Reventlov26-Mar-10 22:00
R. Giskard Reventlov26-Mar-10 22:00 
AnswerRe: Compress a Folder Pin
Nuri Ismail26-Mar-10 22:19
Nuri Ismail26-Mar-10 22:19 
AnswerRe: Compress a Folder Pin
harold aptroot26-Mar-10 22:21
harold aptroot26-Mar-10 22:21 
AnswerRe: Compress a Folder Pin
AspDotNetDev26-Mar-10 23:17
protectorAspDotNetDev26-Mar-10 23:17 
AnswerRe: Compress a Folder Pin
AspDotNetDev26-Mar-10 23:21
protectorAspDotNetDev26-Mar-10 23:21 

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.