Last post Mar 10, 2008 06:05 PM by RobertoPerez
Jan 16, 2007 04:21 PM|dobrien|LINK
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):
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)
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.
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.
Enterprise Library 2.0 Introduction
"Enterprise Library 2.0"
Dec 19, 2007 03:41 PM|beanwa|LINK
I'm having the exact same issue. Did you ever get this resolved?
Mar 10, 2008 06:05 PM|RobertoPerez|LINK
Your parameter declaration is LONG and your type is Int32. Have you missing some cast? Probably you have solved your problem today.