Peter's Gekko

Sponsors

The Lounge

News

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Where it's @ when addressing sql parameters from code.

Speaking of SQL. Take this sql query in a datadapter

SELECT Name, Street FROM Customer WHERE id = @idCust

The @ in front of idCust indicate idCust is a paramater. You can access these parameters from code. Being a bad or lazy typer (I'm both) it's tempting to do this by number.

sqlDataAdapter.SelectCommand.Parameters[0].Value = 12;

In maintanable code it should be done by name

sqlDataAdapter.SelectCommand.Parameters[“@idCust“].Value = 12;

The @ is part of the parameter's name. My first guess would have been different.

Peter

 

 


Posted 04-11-2004 7:20 PM by pvanooijen

[Advertisement]

Comments

Enjoy Every Sandwich wrote Take Outs for 11 April 2004
on 04-11-2004 4:16 PM
Take Outs for 11 April 2004

Add a Comment

(required)  
(optional)
(required)  
Remember Me?