GenericDatabase not passing parameter to stored proc RRS feed

  • Question

  • User-1578243185 posted

    I can't pass parameters to stored procs. 

    I'm using the ODBC class to connect to a SQL Server db with the DAAB. The factory returns a GenericDatabase object for ODBC. I have a stored proc that takes one Integer parameter. I'm adding an "in" parameter and calling ExecuteReader. Pretty basic. I can see in the debugger that the command object has the parameter, so everything seems to be in order. But when I call ExecuteReader, an exception is raised ("Procedure x expects parameter x, which was not supplied."), and the SQL Profiler shows that the parameter isn't being passed. Here's the code (I've genericized some names):

    <WebMethod()> _
    Public Function TransferFile(ByVal myParam As Long) As Integer
        Dim db As Database = DatabaseFactory.CreateDatabase("myDB")
        Dim cmd As DbCommand = db.GetStoredProcCommand("mySP")
        db.AddInParameter(cmd, "@myParam", DbType.Int32, myParam)
        Dim rdr As OdbcDataReader = db.ExecuteReader(cmd)
    End Function

    My connection strings are in web.config, and they seem to be working fine, but I'll include them here in case there is something significant there.
    <ProviderName> System.Data.Odbc
    <DSN> ActualDBName
    <UID> UserID
    <PWD> Password

    On a side note, all it seems I need, as far as config files go, is web.config. I'm a bit confused about what I'd need ConnectionSettings.config or dataConfiguration.config for.

    Tuesday, January 16, 2007 4:21 PM

All replies

  • User468381401 posted

    I'm having the exact same issue.  Did you ever get this resolved?

    Wednesday, December 19, 2007 3:41 PM
  • User2012053744 posted

     Your parameter declaration is LONG and your type is Int32.  Have you missing some cast?  Probably you have solved your problem today.

    Monday, March 10, 2008 6:05 PM