Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Should we escape ' when building command text?
Message
De
31/12/2007 13:43:46
 
 
Information générale
Forum:
ASP.NET
Catégorie:
Bases de données
Versions des environnements
Environment:
ASP.NET
OS:
Windows XP
Database:
MS SQL Server
Divers
Thread ID:
01278630
Message ID:
01278681
Vues:
28
Naomi,

This is just a string. Nothing more. The "@Name" stuff that you would put in that string means nothing at that point ... that's just part of the string. Notice that in my post, I totally got rid of the whole string.Format() part of what you had. You're not putting the actual parameters into that string ... all that goes in that string is the string "@Name".

The parameters come into play when you add them to the Command with the Command.Parameters.AddWithValue() method.

~~Bonnie




>>Not to be mean or anything, Naomi ... but it's really not a good idea to post several un-related questions in one post.
>>
>>1) AFAIK, you can't automatically generate a date in a comment
>>
>>2) The answer I gave before for the parameters applies equally if you're constructing the command with a StringBuilder. Why wouldn't it?
>>
>>~~Bonnie
>>
>
>May be I'm not yet understanding something.
>
>Here is some code:
>
>Command.CommandText = this.RecurrPrograms(ProgramID);
>
>And in the RecurrPrograms method there is a string created
>
>System.Text.StringBuilder RecurrQuery = new System.Text.StringBuilder();
>
>and then
>
>tplEntry = string.Format("INSERT INTO Programs2Times (" +
>                "[ProgramID],[TimeOfProgram],[EndTime],[Fee],[VolunteerFee],[VolunteersReq],[Canceled]" +
>                ",[Facilitator]) VALUES({0},'{{0}} {1}','{{0}} {2}', " +
>                "{3}, {4}, {5}, 0, '{6}')\n", ProgramID, StartTime, EndTime, this.txtbProgFee.Text,
>                VolFee, this.txtbProgVolReq.Text, this.txtbPrgFacilitator.Text);
>
>and appended later in the loop.
>
>How can I apply Parameters here?
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform