Sunday, March 25, 2012

Additional Information

I found the way to pass a open connection (I had been trying to use an ole
connection instead of a sqql connection) so I think I have eliminated that
as a problem. The stack trace seems to imply that it is not happy with the
parameters. I have them defined as follows:
Dim arParms(3) As SqlParameter
arParms(0) = New SqlParameter("@.id", SqlDbType.Int)
arParms(0).Value = Request.Params("ID")
arParms(1) = New SqlParameter("@.clickcount", SqlDbType.Int)
arParms(1).Direction = ParameterDirection.Output
arParms(2) = New SqlParameter("@.url", SqlDbType.VarChar, 100)
arParms(2).Direction = ParameterDirection.Output
Wayne
"Wayne Wengert" <wayneSKIPSPAM@.wengert.org> wrote in message
news:ux63E$T2FHA.400@.TK2MSFTNGP09.phx.gbl...
>I am tyring to use SqlHelper to execute a SP with some passed parameters.
>When I try the statement shown below I get an error "Object reference not
>set to an instance of an object"
> I suspect the connection string as I am not sure exactly what SqlHelper
> wants for that value? I've tried including the provider but it doesn't
> like that. Googling SqlHelper gave me more confusion than help. The
> connection string works fine for normal command use.
> Can anyone point me to some clear information on exactly what the
> SqlHelper command expects in this case? Is there a way to specify an
> existing connection to SqlHelper?
> ===========================
> SqlHelper.ExecuteNonQuery("Data Source = myServer.net; Initial Catalog =
> DB_150547; User ID = myID; Password=myPW", CommandType.StoredProcedure,
> "GetAdClicks", arParms)
>Duihh!!!
The parameter array was Dimed as "3" but there are only 3 elements! The code
was translated from some older "C#" code and they must do it different?
Changed the Dim value to "2" and the problem is solved.
Wayne
"Wayne Wengert" <wayneSKIPSPAM@.wengert.org> wrote in message
news:uTUw5VU2FHA.3964@.TK2MSFTNGP10.phx.gbl...
>I found the way to pass a open connection (I had been trying to use an ole
>connection instead of a sqql connection) so I think I have eliminated that
>as a problem. The stack trace seems to imply that it is not happy with the
>parameters. I have them defined as follows:
> Dim arParms(3) As SqlParameter
> arParms(0) = New SqlParameter("@.id", SqlDbType.Int)
> arParms(0).Value = Request.Params("ID")
> arParms(1) = New SqlParameter("@.clickcount", SqlDbType.Int)
> arParms(1).Direction = ParameterDirection.Output
> arParms(2) = New SqlParameter("@.url", SqlDbType.VarChar, 100)
> arParms(2).Direction = ParameterDirection.Output
> Wayne
>
> "Wayne Wengert" <wayneSKIPSPAM@.wengert.org> wrote in message
> news:ux63E$T2FHA.400@.TK2MSFTNGP09.phx.gbl...
>

No comments:

Post a Comment