Passing SqlParameter not accepting value

T

tshad

I am trying to build my own DB Class and am trying to set up my parameter
list in an array of SqlParameter objects.

In my regular code I would do something like:
*********************************************************
Dim dbCmd As SqlCommand = New SqlCommand("GetUsers", dbConn)
dbCmd.CommandType = CommandType.StoredProcedure

dbCmd.Parameters.Add("@UserID",SqlDBType.Int).value = 1
************************************************************

In this I add the the value dircectly into the .Add SqlParameter statement.

In my class, I get an error if I do the same thing and have to do the
assignment afterwords:
**************************************
Sub LoadGrid()
Dim parameters as SqlParameter() = { _
New SqlParameter("@UserID",SqlDBType.Int) }

parameters(0).value = 1
*****************************************

Is there a way to do the above line in one statement, such as:

New SqlParameter("@UserID",SqlDBType.Int).value = 1

Thanks,

Tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top