[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.odbcnet

ODBC.NET and Stored Procedures

Daniel Reyes

3/16/2002 5:41:00 AM

6 Answers

Scott

3/16/2002 6:56:00 AM

0

Daniel Reyes

3/16/2002 7:05:00 AM

0

Eugen Paval

3/18/2002 8:46:00 PM

0

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
>
>
>
>

(David Sceppa)

3/18/2002 9:38:00 PM

0

Daniel Reyes

3/20/2002 12:52:00 PM

0

David,

I will give that a try.

Is this a known bug in the current released version, or is something messed
up in my installation?

Thanks

"David Sceppa" <davidsc@online.microsoft.com> wrote in message
news:pcg6DzrzBHA.2208@cpmsftngxa09...
> Daniel,
>
> Try using the following CommandText for your Command -
> "{CALL GETTYPEBYNAME(?, ?)}". I believe that should work.
>
> I hope this information proves helpful.
>
> David Sceppa
> Microsoft
> This posting is provided "AS IS" with no warranties,
> and confers no rights. You assume all risk for your use.
> © 2002 Microsoft Corporation. All rights reserved.


(David Sceppa)

3/20/2002 10:19:00 PM

0