Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting the return value from a foxpro stored procedure
Message
General information
Forum:
ASP.NET
Category:
ADO.NET
Miscellaneous
Thread ID:
00821760
Message ID:
00821890
Views:
23
This message has been marked as the solution to the initial question of the thread.
Hi Christopher,

You want to use ExecuteScalar instead of ExecuteNonQuery. ExecuteNonQuery will not return any values where ExecuteScalar will return a value. Change the following:
vfpNextId.ExecuteNonQuery();
to the following:
int myreturn;
myreturn = vfpNextId.ExecuteScalar();
>Is there any way to get a return value from a stored procedure? Here is the code that I am using. I need to get the return value of the stored procedure "getnextid()."
>
>OleDbConnection myConnection = new OleDbConnection();
>myConnection.ConnectionString = ConfigurationSettings.AppSettings["DataPath"];
>
>OleDbCommand vfpNextId = new OleDbCommand();
>vfpNextId.Connection = myConnection;
>vfpNextId.CommandText = "getnextid( asnctlg, id_asnctlg )";
>
>myConnection.Open();
>
>try
>{
> vfpNextId.ExecuteNonQuery();
>}
>catch(Exception ex)
>{
> this.SetError(ex.Message);
> return false;
>}
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform