0

I am looking over some code that another programmer made where he calls a stored procedure. Before calling it, he creates an Array with the parameters needed for the stored procedure to query the table. He creates the array like this:

param = Array("@Name", 3, 8, "Tom", _
            "@Age", 3, 8, 28, _
            "@City", 100, 200, "Toronto)

The stored procedure uses @Name, @Age and @City to query the table.

My question is, what are the numbers in between for?

Kris Krause
  • 7,304
  • 2
  • 23
  • 26
theNoobProgrammer
  • 924
  • 2
  • 15
  • 34
  • 1
    Since there are no code comments (or docs)... can you just ask the other developer? – Kris Krause May 04 '12 at 20:29
  • vbscript is for classic asp. asp.net, as the question is tagged, uses vb.net. Which is right, here? Did you mean to tag your question 'asp-classic' instead of asp.net, did you mean to tag your question 'vb.net' instead of vbscript, or is this a client-side script that only works in internet explorer? – Joel Coehoorn May 04 '12 at 20:44

3 Answers3

2

It looks like:

@Name = parameter name

3 = adInteger

8 = length

"Tom" = value

@Age= parameter name

3 = adInteger

8 = length

28 = value

@City= parameter name

100 = length

200 = adVarChar

"Toronto = value

Here is a list for the other ADO Data Types -

http://www.w3schools.com/ado/ado_datatypes.asp

Kris Krause
  • 7,304
  • 2
  • 23
  • 26
  • Does that mean "Tom" is an integer? If this is asp classic then you're definitely closer to the answer than I am, but it also looks like the 100 and 200 values are in the wrong order. A good puzzle for a Friday afternoon! – mafue May 04 '12 at 21:01
0

Without comments it's impossible to know for sure or without stepping through the code.

Otherwise, if this is asp.net the best you can do is look at the SqlParameter class and see the properties it has available: http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlparameter.aspx

I think you have two strong candidates for ParameterName and Value, but the two numerical values could be a few different things. 3 just happens to be the numerical value for SqlDbType.Char and while 100 has no corresponding SqlDbType, the default for that type is NVarChar.

The next number could be precision. Take a look at the Database table and see if you can match those values to the fields. For example, is City VarChar(200)?

mafue
  • 1,858
  • 1
  • 21
  • 27
0

My guess is that he is using an array of params, just something like this: https://stackoverflow.com/a/10142254/2385, where I use an array of params to pass to a function who add the params to the ADO command.

Community
  • 1
  • 1
Eduardo Molteni
  • 38,786
  • 23
  • 141
  • 206