0

I'm working on a vb.net program for in house use. I've been looking around and trying to understand what the best way to use parameterized queries is. I've seen many places that mention @VarName that would be used as INSERT INTO people (FirstName,LastName) VALUES (@FName,@LName) where each is their respective parameter, but I've also seen several places that say to use positional parameters as ? used as INSERT INTO people (FirstName,LastName) VALUES (?,?) where the first parameter of ? is FirstName and the second is LastName. I'm working with an OpenEdge Progress Database.

Which is the convention for VB.net, if there is one? What is the difference between them?

Tom Bascom
  • 13,405
  • 2
  • 27
  • 33
PsychoData
  • 1,198
  • 16
  • 32

1 Answers1

3

@ Parameters are for the SQL Server native library (using the System.Data.SqlClient library) (or equiv: like Sybase, etc) but ? parameters are for OLEDB (System.Data.OleDb) They are not interchangeable.

TimG
  • 592
  • 2
  • 11
  • I added what system I'm using. It's neither of these. – PsychoData May 02 '14 at 13:43
  • Chances are you're using OLEDB to connect to your datasource as it's a generic API for accessing data in a uniform manner. If you're not using System.Data.OleDb directly then I'd check the documentation for whatever driver you are using to see what it recommend using. – Steve Pettifer May 02 '14 at 14:03
  • I am not familiar with Progress OpenEdge, but if it uses @ for parameters, then I would expect it to be similar (for this answer): use @ param with the native driver or ? param for the OLEDB drivers. – TimG May 02 '14 at 14:14