CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Peter's Gekko

public Blog MyNotepad : Imho { }

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

 

 



Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add
Check out Devlicio.us!

This Blog

Syndication

News