Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Return Error from Stored Procedure with Executescalar
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01536589
Message ID:
01536600
Views:
26
Hi Naomi. Many thanks for replying.
Thats great ..e works great.
Re, running ExecuteScalar twic...I was commenting out various lines during testing and left the extra one in by mistake.... well spotted


Regards,
Gerard


>>Hi.
>>I have the code below, which is going into the Catch Bit, but I dont know why (It does not like the ExecuteScalar bit).
>>Is there a way of returning the Error from a stored procedure when using an ExecuteScalar
>>My Stored procedure is like:
>> Select Sum(MyBalance) as MyBal From MyTable
>>(It works fine in SSMS)
>>
>>Tia
>>Gerard
>>
>>
>>----------------------------------------------------------------------------------------------
>> try
>> {
>> // --- initialization stuff for com ---
>> com.CommandType = CommandType.StoredProcedure;
>> decimal dec = (decimal)com.ExecuteScalar();
>> com.ExecuteScalar(); // E R R O R S O U T H E R E B U T D O N T K N O W W H Y
>> }
>> catch
>> { MessageBox.Show("There has been an error "); }
>>-----------------------------------------------------------------------------------------------
>
>
>catch (Exception e)
>      { MessageBox.Show("There has been an error " + e.Message); }
>
>
>Why do you run ExecuteScalar twice?
Previous
Reply
Map
View

Click here to load this message in the networking platform