Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old January 15th, 2005, 12:12 PM
starazam starazam is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 8 starazam User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Post storedprocedure parameter

hi i hava a stored procedure which accepts some parameters...

previousy i was working with sqlconnection in asp.net to call this storeprocedure.......every thing was working fine

but now when i started to use an odbc connection, when ever i call that stored procedure it give me following error msg... Although i have provided all the parameters it recuires........code is also given below...... plz help soon

Server Error in '/OnlineResume' Application.

ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Procedure 'login' expects parameter '@loginid', which was not supplied.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.Odbc.OdbcException: ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Procedure 'login' expects parameter '@loginid', which was not supplied.

Source Error:



Line 29: sqlcom.Parameters["@loginstatus"].Direction = ParameterDirection.Output;Line 30: sqlcon.Open();Line 31: sqlcom.ExecuteNonQuery();Line 32: int count=Convert.ToInt32(sqlcom.Parameters["@loginstatus"].Value);Line 33: sqlcon.Close();


Source File: f:\onlineresume\onlineresume\jps\users.cs Line: 31

Stack Trace:

code to call is

OdbcCommand sqlcom=new OdbcCommand("login",sqlcon);

sqlcom.CommandType=CommandType.StoredProcedure;

sqlcom.Parameters.Add("@loginid",OdbcType.VarChar);

sqlcom.Parameters["@loginid"].Value=id;

sqlcom.Parameters.Add("@password",OdbcType.VarChar);

sqlcom.Parameters["@password"].Value=password;

sqlcom.Parameters.Add("@loginstatus", OdbcType.Int);

sqlcom.Parameters["@loginstatus"].Direction = ParameterDirection.Output;

sqlcon.Open();

sqlcom.ExecuteNonQuery();

int count=Convert.ToInt32(sqlcom.Parameters["@loginstatus"].Value);




Reply With Quote
  #2  
Old September 25th, 2008, 05:05 AM
iva_registratio iva_registratio is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Sep 2008
Posts: 1 iva_registratio User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 41 sec
Reputation Power: 0
OdbcCommand and StroredProcedure

For ODBC the parameters are positional not named. For C# you would use something like this:

OdbcCommand sqlcom=new OdbcCommand("{call login(?,?,?)}",sqlcon);

Regards, Iva

Quote:
Originally Posted by starazam
hi i hava a stored procedure which accepts some parameters...

previousy i was working with sqlconnection in asp.net to call this storeprocedure.......every thing was working fine

but now when i started to use an odbc connection, when ever i call that stored procedure it give me following error msg... Although i have provided all the parameters it recuires........code is also given below...... plz help soon

Server Error in '/OnlineResume' Application.

ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Procedure 'login' expects parameter '@loginid', which was not supplied.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.Odbc.OdbcException: ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]Procedure 'login' expects parameter '@loginid', which was not supplied.

Source Error:



Line 29: sqlcom.Parameters["@loginstatus"].Direction = ParameterDirection.Output;Line 30: sqlcon.Open();Line 31: sqlcom.ExecuteNonQuery();Line 32: int count=Convert.ToInt32(sqlcom.Parameters["@loginstatus"].Value);Line 33: sqlcon.Close();


Source File: f:\onlineresume\onlineresume\jps\users.cs Line: 31

Stack Trace:

code to call is

[size=2]OdbcCommand sqlcom=
new OdbcCommand("login",sqlcon);

sqlcom.CommandType=CommandType.StoredProcedure;

sqlcom.Parameters.Add("@loginid",OdbcType.VarChar);

sqlcom.Parameters["@loginid"].Value=id;

sqlcom.Parameters.Add("@password",OdbcType.VarChar);

sqlcom.Parameters["@password"].Value=password;

sqlcom.Parameters.Add("@loginstatus", OdbcType.Int);

sqlcom.Parameters["@loginstatus"].Direction = ParameterDirection.Output;

sqlcon.Open();

sqlcom.ExecuteNonQuery();

int count=Convert.ToInt32(sqlcom.Parameters["@loginstatus"].Value);




Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > storedprocedure parameter


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT