Click here to Skip to main content
15,908,445 members
Home / Discussions / C#
   

C#

 
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 
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 
I'm not quite sure what you mean by the second part...

I also tried with a dataset (even though the sp is just an insert) and got the same error. If I don't try to return anything, it's fine.

The code in the helper class goes through quite a bit, so I'll try to paste it as the compiler goes through it.

Step 1:
public static int ExecuteNonQuery(string connectionString, CommandType commandType, string commandText, params SqlParameter[] commandParameters)<br />
		{<br />
			if( connectionString == null || connectionString.Length == 0 ) throw new ArgumentNullException( "connectionString" );<br />
<br />
			// Create & open a SqlConnection, and dispose of it after we are done<br />
			using (SqlConnection connection = new SqlConnection(connectionString))<br />
			{<br />
				connection.Open();<br />
<br />
				// Call the overload that takes a connection in place of the connection string<br />
				return ExecuteNonQuery(connection, commandType, commandText, commandParameters);<br />
			}<br />
		}


Step 2:
public static int ExecuteNonQuery(SqlConnection connection, CommandType commandType, string commandText, params SqlParameter[] commandParameters)<br />
		{	<br />
			if( connection == null ) throw new ArgumentNullException( "connection" );<br />
<br />
			// Create a command and prepare it for execution<br />
			SqlCommand cmd = new SqlCommand();<br />
			bool mustCloseConnection = false;<br />
			PrepareCommand(cmd, connection, (SqlTransaction)null, commandType, commandText, commandParameters, out mustCloseConnection ); RUNS THIS FINE    		<br />
			// Finally, execute the command<br />
			int retval = cmd.ExecuteNonQuery(); GETS STUCK ON THIS<br />
    		<br />
			// Detach the SqlParameters from the command object, so they can be used again<br />
			cmd.Parameters.Clear();<br />
			if( mustCloseConnection )<br />
				connection.Close();<br />
			return retval;<br />
		}


If there is a quick and painless other way to do this I'm all ears...or eyes really. I just want to get done with this!

Smile | :) Smile | :)
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 
AnswerRe: return code from console application Pin
led mike12-Jul-06 9:56
led mike12-Jul-06 9:56 
GeneralRe: return code from console application Pin
Petes197312-Jul-06 10:02
Petes197312-Jul-06 10:02 
GeneralRe: return code from console application Pin
led mike12-Jul-06 10:17
led mike12-Jul-06 10:17 
GeneralRe: return code from console application Pin
Petes197312-Jul-06 10:30
Petes197312-Jul-06 10:30 

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.