Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Quick check - can we use string function as void?
Message
From
08/08/2008 13:57:08
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 3.0
OS:
Windows XP
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01337589
Message ID:
01337612
Views:
9
Como quieras
__

>Hi Gregory,
>
>I've checked how the procedure is declared and I see that it returns integer. But when I call it, I don't declare int and it works fine. So, from this I may assume if I would have returned string I would not need to capture the output.
>
>In any case, I think I better create a different function with slightly different functionality. I checked and the current implementation doesn't catch the error at all.
>
>>>Hi everybody,
>>>
>>>I have a static void function to execute a stored procedure. It has try/catch block, but it doesn't do anything with the exception. I was thinking I would return the exception message as a string to the calling program. The problem is - this function is used in many places and I don't want to change all of them.
>>>
>>>What would be a good way for me to retrieve the info?
>>>
>>>Is it possible to call string returning function as it doesn't return anything?
>>>
>>>Thanks in advance.
>>_
>>
>>You can overload it - one method calls the other
>>
>>
>>
>>static void SomeProc()
>>{
>>  string something;
>>
>>  SomeProc(out something);
>>}
>>
>>static void SomeProc( string out s)
>>{
>>
>>   if( ... )
>>     s = null;
>>   else
>>     s = "ppp"
>>}
>>
>>
>>
>>__
>>also possible (cannot test it - am without vs2008 for the moment
>>
>>
>>static void SomeProc()
>>{
>>  string something;
>>
>>  something = SomeProc();
>>}
>>
>>static string SomeProc( )
>>{
>>
>>   if( ... )
>>    return null;
>>   else
>>    return "ppp"
>>}
>>
Gregory
Previous
Reply
Map
View

Click here to load this message in the networking platform