Click here to Skip to main content
16,003,383 members
Home / Discussions / C#
   

C#

 
QuestionPls Help Me !!! Pin
Fahad Ali12-Jul-06 11:51
Fahad Ali12-Jul-06 11:51 
AnswerRe: Pls Help Me !!! Pin
PlayByTheRules12-Jul-06 22:05
PlayByTheRules12-Jul-06 22:05 
QuestionHow can create Software lock in C# ? Pin
persian_king12-Jul-06 11:39
persian_king12-Jul-06 11:39 
AnswerRe: How can create Software lock in C# ? Pin
Not Active12-Jul-06 14:00
mentorNot Active12-Jul-06 14:00 
AnswerRe: How can create Software lock in C# ? Pin
Divyang Mithaiwala12-Jul-06 20:23
Divyang Mithaiwala12-Jul-06 20:23 
QuestionPropertyGrid meets Generics Pin
Mattman20612-Jul-06 11:16
Mattman20612-Jul-06 11:16 
AnswerRe: PropertyGrid meets Generics [modified] Pin
Mattman20612-Jul-06 16:25
Mattman20612-Jul-06 16:25 
QuestionProblem with code returning parameter from stored procedure Pin
leckey12-Jul-06 10:26
leckey12-Jul-06 10:26 
I first tried this code that passes a couple of parameters (part number, part type number) to a stored procedure. I can get this to run fine, insert the data into the table, no problem.

However, I want the stored procedure to return a field that is an auto-increment field called ID.

The stored procedure is syntactically correct, so I'm inclined to think it's something with the C# code.

The error I'm getting is: Parameter1 is not a parameter for procedure UpdatePart_Step_1_Test3

This is the c# code (note that I have so additional parameters that I declare but am not yet passing):
private void btnAdd_Click(object sender, System.EventArgs e)<br />
		{<br />
			strPartNumberInputReference = txtSearchPart.Text;<br />
			strPartTypeID = ddPartType.SelectedValue;<br />
			strDwgNumber = txtDwgNumber.Text;<br />
			strDwgRevision = txtDwgRevision.Text;<br />
			strDwgLocation = txtDwgLocation.Text;	<br />
			SqlParameter param1 = new SqlParameter("@PartNumber", strPartNumberInputReference);	<br />
			param1.Direction = ParameterDirection.Input;<br />
			//SqlParameter param2 = new SqlParameter("@DwgNumber", strDwgNumber);<br />
			//SqlParameter param3 = new SqlParameter("@DwgRevision", strDwgRevision);<br />
			//SqlParameter param4 = new SqlParameter("@DwgLocation", strDwgLocation);<br />
			SqlParameter param5 = new SqlParameter("@PartTypeValue", strPartTypeID);<br />
			SqlParameter param6 = new SqlParameter(@ID, SqlDbType.Int);<br />
			param6.Direction = ParameterDirection.Output;<br />
			IDOutput = SqlHelper.ExecuteNonQuery (this.connectionString, CommandType.StoredProcedure, "dbo.UpdatePart_Step_1_Test3", param1, param5, param6);<br />
			test3 = param6.Value;<br />
	<br />
		}


Here is the stored proc:
CREATE PROCEDURE [dbo].[UpdatePart_Step_1_Test3]<br />
@PartNumber varchar (15),<br />
@PartTypeValue varchar (60),<br />
@ID int OUTPUT<br />
<br />
AS<br />
<br />
if NOT EXISTS (Select * from PartsDB.dbo.Parts where PartNumber = @PartNumber)<br />
BEGIN<br />
<br />
insert into PartsDB.dbo.Parts<br />
(PartNumber, PartTypeID)<br />
<br />
VALUES<br />
(<br />
@PartNumber,<br />
@PartTypeValue<br />
)<br />
<br />
END<br />
SET @ID = @@IDENTITY<br />
<br />
return 0<br />
GO


Again, if I just send in param1 and param 5 (and change the stored proc so it's not expecting a third parameter) it works fine!

Any ideas what is causing the error? I'm not finding any documentation.
AnswerRe: Problem with code returning parameter from stored procedure Pin
Christian Graus12-Jul-06 10:35
protectorChristian Graus12-Jul-06 10:35 
GeneralRe: Problem with code returning parameter from stored procedure Pin
led mike12-Jul-06 10:43
led mike12-Jul-06 10:43 
GeneralRe: Problem with code returning parameter from stored procedure Pin
leckey12-Jul-06 10:45
leckey12-Jul-06 10:45 
GeneralRe: Problem with code returning parameter from stored procedure Pin
leckey12-Jul-06 10:44
leckey12-Jul-06 10:44 
GeneralRe: Problem with code returning parameter from stored procedure Pin
Christian Graus12-Jul-06 10:48
protectorChristian Graus12-Jul-06 10:48 
GeneralRe: Problem with code returning parameter from stored procedure Pin
leckey12-Jul-06 10:50
leckey12-Jul-06 10:50 
GeneralRe: Problem with code returning parameter from stored procedure Pin
Christian Graus12-Jul-06 10:58
protectorChristian Graus12-Jul-06 10:58 
GeneralRe: Problem with code returning parameter from stored procedure Pin
leckey12-Jul-06 11:02
leckey12-Jul-06 11:02 
GeneralRe: Problem with code returning parameter from stored procedure Pin
Christian Graus12-Jul-06 11:09
protectorChristian Graus12-Jul-06 11:09 
GeneralRe: Problem with code returning parameter from stored procedure Pin
leckey12-Jul-06 11:15
leckey12-Jul-06 11:15 
GeneralRe: Problem with code returning parameter from stored procedure Pin
Christian Graus12-Jul-06 11:17
protectorChristian Graus12-Jul-06 11:17 
GeneralRe: Problem with code returning parameter from stored procedure Pin
Christian Graus12-Jul-06 11:09
protectorChristian Graus12-Jul-06 11:09 
AnswerRe: Problem with code returning parameter from stored procedure [modified] Pin
Jon Sagara12-Jul-06 11:14
Jon Sagara12-Jul-06 11:14 
GeneralRe: Problem with code returning parameter from stored procedure Pin
leckey12-Jul-06 11:24
leckey12-Jul-06 11:24 
GeneralRe: Problem with code returning parameter from stored procedure Pin
Christian Graus12-Jul-06 11:36
protectorChristian Graus12-Jul-06 11:36 
GeneralRe: Problem with code returning parameter from stored procedure Pin
leckey12-Jul-06 11:50
leckey12-Jul-06 11:50 
Questionreturn code from console application Pin
Petes197312-Jul-06 9:45
Petes197312-Jul-06 9:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.