Eugen Paval
3/18/2002 8:46:00 PM
According to MS's KB article Q309486 calling a stored
procedure with ODBC.NET uses the old ODBC syntax ({?ÊLL
ProcName(?)}. You may want to try that.
Regards,
Eugen
>-----Original Message-----
>Hi All,
>
>I hope someone can help out with this problem, because
it's driving me crazy.
>
>To start of, i have the latest versions of
Microsoft.data.odbc, MDAC2.7RTM, .NET Framework RTM, SQL
Server 2000 SP2.
>
>Everything works fine until i use a stored procedure
with input parameters. When i do, i get the following
error:
>
>"Microsoft.Data.Odbc.OdbcException: ERROR [42000]
[Microsoft][ODBC SQL Server Driver][SQL Server]
Procedure 'GETTYPEBYNAME' expects parameter '@Name',
which was not supplied."
>
>Here is a simple code example for illustration purposes,
that causes this:
>String myConnectionString = "DRIVER={SQL
Server};SERVER7.0.0.1;UID=sa;Trusted_connection=true;DA
TABASE=TEST;";
>
>OdbcConnection myConn = new OdbcConnection
(myConnectionString);
>myConn.Open();
>OdbcCommand myOdbcCommand = new OdbcCommand
("GETTYPEBYNAME",myConn);
>myOdbcCommand.Parameters.Add("@Name", OdbcType.VarChar,
50).Value = "Size";
>myOdbcCommand.Parameters.Add("@ClassID", OdbcType.Int,
4).Value = 1;
>myOdbcCommand.ExecuteNonQuery();
>
>Here is the stored procedure:
>
>CREATE Procedure GETTYPEBYNAME
>(
>@Name varchar(50),
>@ClassID int
>)
>As
>SELECT TypeID,[Name]
>FROM TYPE
>WHERE ([NAME]=@Name) AND (ClassID=@ClassID)
>
>Ive used the same exact method with
system.data.sqlclient and system.data.oledb (with syntax
changes of course) against the same database, with no
problems. Iam fairly sure thats its not a code issue, or
a database issue (ive also tried the same on SQL Server 7
database server). Ive also tried other stored procedures,
with the same result.
>
>Any help is appreciated.
>
>Thanks
>
>
>
>