By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,335 Members | 1,310 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,335 IT Pros & Developers. It's quick & easy.

OdbcParameter problem

P: n/a
When I execute the following code I get the error..

Stored procedure get_nextid expects parameter @next_id which was not
supplied

What am I doing wrong

public String GetNewKey()

{

String myid = "";

OdbcConnection myConnection = new
OdbcConnection("DSN=RMS5SQL_DSN;UID=FireRMS5_USER; PWD=98953");

myConnection.Open();

OdbcCommand myCommand = new OdbcCommand("get_nextid", myConnection);

myCommand.CommandType = CommandType.StoredProcedure;

OdbcParameter workParam = null;

workParam = myCommand.Parameters.Add("@next_id", OdbcType.Int);

workParam.Direction = ParameterDirection.Output;

myCommand.ExecuteNonQuery();

myid = myCommand.Parameters["@next_id"].Value.ToString();

//pad with "_000" to 14 length (Typical key in FireRMS)

myid = myid.PadLeft(14,'0');

return myid;

}
Nov 13 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
In the Stored Procedure, is @next_id declared as OUTPUT? Clearly it
is in your code but it must also be set in the actual SP.

Jonathan Schafer
On Mon, 14 Jul 2003 14:24:55 -0400, "Mike McCarthy"
<mm*******@aethersystems.com> wrote:
When I execute the following code I get the error..

Stored procedure get_nextid expects parameter @next_id which was not
supplied

What am I doing wrong

public String GetNewKey()

{

String myid = "";

OdbcConnection myConnection = new
OdbcConnection("DSN=RMS5SQL_DSN;UID=FireRMS5_USER ;PWD=98953");

myConnection.Open();

OdbcCommand myCommand = new OdbcCommand("get_nextid", myConnection);

myCommand.CommandType = CommandType.StoredProcedure;

OdbcParameter workParam = null;

workParam = myCommand.Parameters.Add("@next_id", OdbcType.Int);

workParam.Direction = ParameterDirection.Output;

myCommand.ExecuteNonQuery();

myid = myCommand.Parameters["@next_id"].Value.ToString();

//pad with "_000" to 14 length (Typical key in FireRMS)

myid = myid.PadLeft(14,'0');

return myid;

}


Nov 13 '05 #2

P: n/a
I created the SP on our SqlServer 2k, and copied your code below to
call it. However, I don't have .NET framework 1.1, so I had to change
the Odbc stuff to Sql stuff (SqlConnection, SqlCommand).

The code compile, ran, and returned the correct value. Without having
the 1.1 framework, I can't reproduce the problem.

Jonathan Schafer
On Mon, 14 Jul 2003 16:19:06 -0400, "Mike McCarthy"
<mm*******@aethersystems.com> wrote:
Here's a copy of the sotred procedure...

CREATE PROCEDURE dbo.get_nextid @next_id int out AS
UPDATE nextid SET @next_id = id = id+1

GO

"Jonathan Schafer" <jschafer@*NOSPAM*brierley.a.b.c.com> wrote in message
news:l1********************************@4ax.com.. .
In the Stored Procedure, is @next_id declared as OUTPUT? Clearly it
is in your code but it must also be set in the actual SP.

Jonathan Schafer
On Mon, 14 Jul 2003 14:24:55 -0400, "Mike McCarthy"
<mm*******@aethersystems.com> wrote:
>When I execute the following code I get the error..
>
>Stored procedure get_nextid expects parameter @next_id which was not
>supplied
>
>What am I doing wrong
>
>public String GetNewKey()
>
>{
>
>String myid = "";
>
>OdbcConnection myConnection = new
>OdbcConnection("DSN=RMS5SQL_DSN;UID=FireRMS5_USER ;PWD=98953");
>
>myConnection.Open();
>
>
>
>OdbcCommand myCommand = new OdbcCommand("get_nextid", myConnection);
>
>myCommand.CommandType = CommandType.StoredProcedure;
>
>OdbcParameter workParam = null;
>
>workParam = myCommand.Parameters.Add("@next_id", OdbcType.Int);
>
>workParam.Direction = ParameterDirection.Output;
>
>myCommand.ExecuteNonQuery();
>
>myid = myCommand.Parameters["@next_id"].Value.ToString();
>
>//pad with "_000" to 14 length (Typical key in FireRMS)
>
>myid = myid.PadLeft(14,'0');
>
>return myid;
>
>}
>


Nov 13 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.