Click here to Skip to main content
16,020,253 members
Home / Discussions / C#
   

C#

 
AnswerRe: How I can Read this File in C# Pin
Not Active13-Jul-06 7:43
mentorNot Active13-Jul-06 7:43 
AnswerRe: How I can Read this File in C# Pin
stancrm13-Jul-06 8:32
stancrm13-Jul-06 8:32 
GeneralRe: How I can Read this File in C# Pin
Dave Kreskowiak13-Jul-06 9:02
mveDave Kreskowiak13-Jul-06 9:02 
QuestionHow to drag and drop datagrid cells? Pin
Kenneth Mora Flores13-Jul-06 7:34
Kenneth Mora Flores13-Jul-06 7:34 
QuestionBinding Combobox to related tables ! Pin
User 209307313-Jul-06 6:48
User 209307313-Jul-06 6:48 
QuestionHow to modified text file in C Pin
arun.m13-Jul-06 6:02
arun.m13-Jul-06 6:02 
AnswerRe: How to modified text file in C Pin
Christian Graus13-Jul-06 6:03
protectorChristian Graus13-Jul-06 6:03 
QuestionLosing value of object Pin
leckey13-Jul-06 5:54
leckey13-Jul-06 5:54 
I have an asp.net application. User enters some data into some text fields and such and clicks a button. The button runs a stored procedure. The stored procedure returns an ID number that I need to use in subsequent pages. Within the section that runs the stored procedure, the ID (called IDOutput2) retains its value. However, when I try to access it outside the function, I lose its value. I thought I had declared everything properly, but obviously I'm missing something.

public object IDOutput2;<br />
.<br />
.<br />
.<br />
public 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 />
			SqlParameter param2 = new SqlParameter("@PartTypeValue", strPartTypeID);<br />
			SqlParameter param3 = new SqlParameter("@ID", SqlDbType.Int);<br />
			param3.Direction = ParameterDirection.Output;<br />
			 try<br />
			{<br />
				IDOutput = SqlHelper.ExecuteNonQuery (this.connectionString, CommandType.StoredProcedure, "dbo.UpdatePart_Step_1", param1, param2, param3);<br />
				IDOutput2 = param3.Value;<br />
				SqlParameter param4 = new SqlParameter("@DwgRevision", strDwgRevision);<br />
				SqlParameter param5 = new SqlParameter("@DwgNumber", strDwgNumber);<br />
				SqlParameter param6 = new SqlParameter("@DwgLocation", strDwgLocation);<br />
				SqlParameter param7 = new SqlParameter("@ID2", IDOutput2);<br />
				IDOutput = SqlHelper.ExecuteNonQuery (this.connectionString, CommandType.StoredProcedure, "dbo.UpdatePart_Step_1_part2", param4, param5, param6, param7);<br />
				Response.Write ("Successful update.");<br />
				txtSearchPart.Text = "";<br />
				txtDwgNumber.Text = "";<br />
				txtDwgLocation.Text = "";<br />
				txtDwgRevision.Text = "";<br />
				ddPartType.SelectedIndex = 1;<br />
				 Response.Write (IDOutput2);<br />
				//return IDOutput2;<br />
			}<br />
<br />
			catch<br />
			{<br />
				Response.Write ("Insert failed.");<br />
			}<br />
<br />
		}


I tried changing the function to:public object btnAdd_Click(object sender, System.EventArgs e) and do a return IDOutput2 but I got the error that not all paths return a value.

How do I fix this?
AnswerRe: Losing value of object Pin
Christian Graus13-Jul-06 6:02
protectorChristian Graus13-Jul-06 6:02 
GeneralRe: Losing value of object Pin
leckey13-Jul-06 6:05
leckey13-Jul-06 6:05 
AnswerRe: Losing value of object Pin
Guffa13-Jul-06 9:04
Guffa13-Jul-06 9:04 
GeneralRe: Losing value of object Pin
leckey13-Jul-06 9:57
leckey13-Jul-06 9:57 
AnswerRe: Losing value of object Pin
Guffa13-Jul-06 11:55
Guffa13-Jul-06 11:55 
AnswerRe: Losing value of object Pin
Josh Smith13-Jul-06 6:06
Josh Smith13-Jul-06 6:06 
GeneralRe: Losing value of object Pin
leckey13-Jul-06 6:11
leckey13-Jul-06 6:11 
GeneralRe: Losing value of object Pin
Josh Smith13-Jul-06 7:44
Josh Smith13-Jul-06 7:44 
QuestionHow to implement Trees ... Pin
JamesT113-Jul-06 5:38
JamesT113-Jul-06 5:38 
AnswerRe: How to implement Trees ... Pin
Christian Graus13-Jul-06 5:45
protectorChristian Graus13-Jul-06 5:45 
GeneralRe: How to implement Trees ... Pin
Josh Smith13-Jul-06 5:50
Josh Smith13-Jul-06 5:50 
GeneralRe: How to implement Trees ... Pin
Christian Graus13-Jul-06 5:53
protectorChristian Graus13-Jul-06 5:53 
GeneralRe: How to implement Trees ... Pin
Josh Smith13-Jul-06 5:59
Josh Smith13-Jul-06 5:59 
GeneralRe: How to implement Trees ... Pin
led mike13-Jul-06 7:28
led mike13-Jul-06 7:28 
AnswerRe: How to implement Trees ... Pin
Jun Du13-Jul-06 5:51
Jun Du13-Jul-06 5:51 
AnswerRe: How to implement Trees ... [modified] Pin
User 665813-Jul-06 5:53
User 665813-Jul-06 5:53 
AnswerRe: How to implement Trees ... Pin
BoneSoft13-Jul-06 6:13
BoneSoft13-Jul-06 6:13 

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.