Click here to Skip to main content
15,896,432 members
Home / Discussions / C#
   

C#

 
GeneralRe: parameterized query Pin
jdkulkarni28-Aug-05 18:19
jdkulkarni28-Aug-05 18:19 
GeneralRe: parameterized query Pin
Luis Alonso Ramos25-Aug-05 19:43
Luis Alonso Ramos25-Aug-05 19:43 
GeneralRe: parameterized query Pin
jdkulkarni25-Aug-05 19:54
jdkulkarni25-Aug-05 19:54 
GeneralRe: parameterized query Pin
Daniel Turini26-Aug-05 2:12
Daniel Turini26-Aug-05 2:12 
GeneralRe: parameterized query Pin
Not Active26-Aug-05 3:08
mentorNot Active26-Aug-05 3:08 
GeneralRe: parameterized query Pin
jdkulkarni26-Aug-05 3:23
jdkulkarni26-Aug-05 3:23 
GeneralRe: parameterized query Pin
Not Active26-Aug-05 3:33
mentorNot Active26-Aug-05 3:33 
AnswerRe: parameterized query Pin
Luis Alonso Ramos26-Aug-05 3:54
Luis Alonso Ramos26-Aug-05 3:54 
Just type something with a ' in there and you code will blow up. If you have a text box where I enter a date, and I change the culture of the operating system, you'll get erroneous date.

It's really easy to have parameterized queries, and even access has them. Compare this:
string sql = "SELECT * FROM Users WHERE UserName = '" + txtUserName.Text "' AND Password = '" + txtPassword.Text + "'";
OleDbCommand cmd = new OleDbCommand(cmd, conn);
to this:
string sql = "SELECT * FROM Users WHERE UserName = ? AND Password = ?";
OleDbCommand cmd = new OleDbCommand(cmd, conn);
cmd.Parameters.Add("", txtUserName.Text);  // In Access, parameter name doesn't
cmd.Parameters.Add("", txtPassword.Text);  // matter, it's by position
Easier to read in my opinion, way much more secure and robust, and easier to maintain.

-- LuisR




Luis Alonso Ramos
Intelectix - Chihuahua, Mexico

Not much here: My CP Blog!


The amount of sleep the average person needs is five more minutes. -- Vikram A Punathambekar, Aug. 11, 2005
GeneralRe: parameterized query Pin
nidhelp26-Aug-05 6:10
nidhelp26-Aug-05 6:10 
QuestionTEXT BOX TEXT TO DOUBLE? Pin
...---...25-Aug-05 14:56
...---...25-Aug-05 14:56 
AnswerRe: TEXT BOX TEXT TO DOUBLE? Pin
Luis Alonso Ramos25-Aug-05 16:49
Luis Alonso Ramos25-Aug-05 16:49 
GeneralRe: TEXT BOX TEXT TO DOUBLE? Pin
...---...25-Aug-05 17:02
...---...25-Aug-05 17:02 
JokeRe: TEXT BOX TEXT TO DOUBLE? Pin
Luis Alonso Ramos25-Aug-05 18:03
Luis Alonso Ramos25-Aug-05 18:03 
QuestionRetrieve the value of Inout parameter Pin
tsramkumar25-Aug-05 11:35
tsramkumar25-Aug-05 11:35 
AnswerRe: Retrieve the value of Inout parameter Pin
miah alom25-Aug-05 11:42
miah alom25-Aug-05 11:42 
GeneralRe: Retrieve the value of Inout parameter Pin
tsramkumar25-Aug-05 11:46
tsramkumar25-Aug-05 11:46 
GeneralRe: Retrieve the value of Inout parameter Pin
miah alom25-Aug-05 11:52
miah alom25-Aug-05 11:52 
GeneralRe: Retrieve the value of Inout parameter Pin
tsramkumar25-Aug-05 12:56
tsramkumar25-Aug-05 12:56 
AnswerRe: Retrieve the value of Inout parameter Pin
Luis Alonso Ramos25-Aug-05 17:19
Luis Alonso Ramos25-Aug-05 17:19 
GeneralRe: Retrieve the value of Inout parameter Pin
tsramkumar26-Aug-05 1:35
tsramkumar26-Aug-05 1:35 
Questionxs:date type in DataSet Pin
tadass25-Aug-05 11:10
tadass25-Aug-05 11:10 
QuestionUsing ArrayList Pin
MarkMokris25-Aug-05 10:49
MarkMokris25-Aug-05 10:49 
AnswerRe: Using ArrayList Pin
gnjunge25-Aug-05 10:54
gnjunge25-Aug-05 10:54 
GeneralRe: Using ArrayList Pin
Daniel132425-Aug-05 13:33
Daniel132425-Aug-05 13:33 
AnswerRe: Using ArrayList Pin
Matt Gerrans25-Aug-05 16:59
Matt Gerrans25-Aug-05 16:59 

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.