﻿<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>StrataFrame Forum » StrataFrame Application Framework - V1 » WinForms (How do I?)  » How to call stored procdure and return different type value?</title><generator>InstantForum 2017-1 Final</generator><description>StrataFrame Forum</description><link>http://forum.strataframe.net/</link><webMaster>StrataFrame Forum</webMaster><lastBuildDate>Tue, 09 Jun 2026 07:38:00 GMT</lastBuildDate><ttl>20</ttl><item><title>How to call stored procdure and return different type value?</title><link>http://forum.strataframe.net/FindPost22665.aspx</link><description>Dear All,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I have created a stored procdure name sp_GetInfoCurrency&amp;nbsp; and the codeing as bellow:&lt;/P&gt;&lt;P&gt;CREATE PROCEDURE [dbo].[sp_GetInfoCurrency]&lt;BR&gt;&amp;nbsp;@pcurcode nchar(5),&lt;BR&gt;&amp;nbsp;@pcurid int output,&lt;BR&gt;&amp;nbsp;@pcurname nvarchar(50) output,&lt;BR&gt;&amp;nbsp;@pcurrate smallmoney output&lt;BR&gt;AS&lt;BR&gt;BEGIN&lt;BR&gt;&amp;nbsp;SET NOCOUNT ON;&lt;/P&gt;&lt;P&gt;&amp;nbsp;select @pcurid=curid, @pcurname=curname, @pcurrate=currate from currency where &lt;A href="mailto:curcode=@pcurcode"&gt;curcode=@pcurcode&lt;/A&gt;&lt;BR&gt;&amp;nbsp;if @pcurid is null&lt;BR&gt;&amp;nbsp;begin&lt;BR&gt;&amp;nbsp;&amp;nbsp;set @pcurid=0&lt;BR&gt;&amp;nbsp;&amp;nbsp;set @pcurname=''&lt;BR&gt;&amp;nbsp;&amp;nbsp;set @pcurrate=0&lt;BR&gt;&amp;nbsp;end&lt;BR&gt;END&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; My question is, How to call the stored procdure through StrataFrame, Is there any method or fuctions easy to do this?&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Please provide the sample code.&lt;/P&gt;&lt;P&gt;Thanks.</description><pubDate>Thu, 16 Apr 2009 05:30:58 GMT</pubDate><dc:creator>Raymond Lo</dc:creator></item><item><title>RE: How to call stored procdure and return different type value?</title><link>http://forum.strataframe.net/FindPost22746.aspx</link><description>Thanks Trent, &lt;/P&gt;&lt;P&gt;It's work.</description><pubDate>Thu, 16 Apr 2009 05:30:58 GMT</pubDate><dc:creator>Raymond Lo</dc:creator></item><item><title>RE: How to call stored procdure and return different type value?</title><link>http://forum.strataframe.net/FindPost22743.aspx</link><description>[quote]Isn't there extra overhead by calling the sproc from within the BO?[/quote]&lt;/P&gt;&lt;P&gt;Not really, no.&amp;nbsp; I would say that 80% of all SPROCs that we execute are through a BO...if not more.&amp;nbsp; I am being conservative.&amp;nbsp; Most times you are using a SPROC to load or update data.&amp;nbsp; Especially ini the case of retrieving result sets, you would have fewer steps by doing this within the BO itself.&lt;/P&gt;&lt;P&gt;[quote]Is it possible that I lose something, though, by not going through the BO?&lt;BR&gt;[/quote]&lt;/P&gt;&lt;P&gt;Well, if you are trying to retrieve result sets, then this is going to be more overhead as now you have to get the result sets into BOs.&amp;nbsp; When we write report data sources, we may have as many as 20 result sets (or even more) in some cases.&amp;nbsp; In this scenario, we will use the FillMultipleDataTables method on the BusinessLayer.&amp;nbsp; This way we can populate all of the BOs at the same time in one foul swoop.&amp;nbsp; This is significantly faster when pulling back multiple result sets.</description><pubDate>Wed, 15 Apr 2009 10:46:38 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: How to call stored procdure and return different type value?</title><link>http://forum.strataframe.net/FindPost22742.aspx</link><description>Isn't there extra overhead by calling the sproc from within the BO?  I would assume that the entire BO needs to be instantiated before the code can run the sproc; however, in the call from outside the BO, that is never the case.  Is it possible that I lose something, though, by not going through the BO?&lt;br&gt;
&lt;br&gt;
I have used both ways of executing an sproc...just wondering which is the cleaner way.&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
Bill</description><pubDate>Wed, 15 Apr 2009 10:32:29 GMT</pubDate><dc:creator>Bill Cunnien</dc:creator></item><item><title>RE: How to call stored procdure and return different type value?</title><link>http://forum.strataframe.net/FindPost22723.aspx</link><description>Raymond, I see a number of minor issues here, but the biggest "question mark" that I have is that is where you are trying to execute this query and why you aren't going through a business object.&amp;nbsp; Even if you wanted to execute this outside of a BO, you still never need to set the connection in SF, it will handle this for you.&lt;/P&gt;&lt;P&gt;In regards to some issues, you were creating two commands, one of which did not specify the SPROC.&amp;nbsp; Since you were reusing the same variable, the code at the top was unnecessary.&amp;nbsp; Then when you create the second SqlCommand, the variable will no longer exist.&amp;nbsp; Below would be a better example of how to execute this.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Calling from within a BO&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;[codesnippet]Dim cmd As New SqlCommand("dbo.sp_GetInfoCurrency")&lt;/P&gt;&lt;P&gt;cmd.CommandType = CommandType.StoredProcedure&lt;BR&gt;cmd.Parameters.Add("@pcurcode", SqlDbType.Char).Value&amp;nbsp; = me.cboCurrency.Text&lt;BR&gt;Me.ExecuteNonQuery(cmd)[/codesnippet]&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Calling Outside of a BO&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;[codesnippet]Dim cmd As New SqlCommand("dbo.sp_GetInfoCurrency")&lt;/P&gt;&lt;P&gt;cmd.CommandType = CommandType.StoredProcedure&lt;BR&gt;cmd.Parameters.Add("@pcurcode", SqlDbType.Char).Value&amp;nbsp; = me.cboCurrency.Text&lt;BR&gt;MicroFour.StrataFrame.DataBasics.DataSources("").ExecuteNonQuery(cmd)[/codesnippet]</description><pubDate>Wed, 15 Apr 2009 08:41:29 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: How to call stored procdure and return different type value?</title><link>http://forum.strataframe.net/FindPost22720.aspx</link><description>Dear&amp;nbsp; Greg /Trent ,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I can not apply the coding to my Queuies.vb&amp;nbsp; success (all functions in this file), It alway show : Me.ExecuteNonQuery(cmd) --don't accept any parameters. I want to know , Is this code must apply in the BO as a BO method ?&lt;BR&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I only want to call my stored procedure and return the value (string or integer). My new coding as bellow but still not work. The error show that "miss the parameter @pcurcode"&amp;nbsp; I don't know where is wrong.&amp;nbsp; Can you help me check?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim cmd As New SqlCommand()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Dim conn As New SqlConnection(MicroFour.StrataFrame.Data.DataBasics.DataSources("").ConnectionString)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; conn.Open()&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmd.CommandType = CommandType.StoredProcedure&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmd.Parameters.Add("@pcurcode", SqlDbType.Char, 5)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmd.Parameters("@pcurcode").Value = Me.cboCurrency.Text&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmd = New SqlClient.SqlCommand("sp_GetInfoCurrency", conn)&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cmd.ExecuteNonQuery()&lt;BR&gt;</description><pubDate>Wed, 15 Apr 2009 05:16:17 GMT</pubDate><dc:creator>Raymond Lo</dc:creator></item><item><title>RE: How to call stored procdure and return different type value?</title><link>http://forum.strataframe.net/FindPost22668.aspx</link><description>That is what Greg is showing you.&amp;nbsp; The Me.ExecuteNonQuery is being executed on the BO, so when you pass over the SqlCommand it will update the Connection of that object through the BO without any additional coding.</description><pubDate>Tue, 07 Apr 2009 09:32:03 GMT</pubDate><dc:creator>Trent L. Taylor</dc:creator></item><item><title>RE: How to call stored procdure and return different type value?</title><link>http://forum.strataframe.net/FindPost22667.aspx</link><description>Hi Greg McGuffey,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Thank you very much!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Is there any way through StrataFrame to call this procdure and return the value? Because I want to using the StrataFrame connections to retrieve the data.&lt;/P&gt;&lt;P&gt;Regards,</description><pubDate>Tue, 07 Apr 2009 04:25:15 GMT</pubDate><dc:creator>Raymond Lo</dc:creator></item><item><title>RE: How to call stored procdure and return different type value?</title><link>http://forum.strataframe.net/FindPost22666.aspx</link><description>Raymond,&lt;br&gt;
&lt;br&gt;
This is very easy!  The trick is to use parameters to get the return data.  I'm just typing this, so the enums for CommandType, Direction and SqlDataType aren't exactly accurate (intellisense will fix 'em right up though!).&lt;br&gt;
&lt;br&gt;
[codesnippet]'-- Assumes that pcurcode is provided via a method argument&lt;br&gt;
Using cmd As New SqlCommand()&lt;br&gt;
&amp;nbsp;&amp;nbsp;'-- Setup sproc&lt;br&gt;
&amp;nbsp;&amp;nbsp;cmd.CommandType = StoredProcedure&lt;br&gt;
&amp;nbsp;&amp;nbsp;cmd.CommandText = "sp_GetInfoCurrency"&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;'-- Add input param&lt;br&gt;
&amp;nbsp;&amp;nbsp;cmd.Parameters.Add("@pcurcode",char,5)&lt;br&gt;
&amp;nbsp;&amp;nbsp;cmd.Parameters("@pcurcode").Value = pcurcode&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;'-- Add output params&lt;br&gt;
&amp;nbsp;&amp;nbsp;cmd.Parameters.Add("@pcurid",int).Direction = Output&lt;br&gt;
&amp;nbsp;&amp;nbsp;cmd.Parameters.Add("@pcurname",nvarchar,50).Direction = Output&lt;br&gt;
&amp;nbsp;&amp;nbsp;cmd.Parameters.Add("@pcurrate",smallmoney).Direction = Output&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;'-- Execute spoc&lt;br&gt;
&amp;nbsp;&amp;nbsp;Me.ExecuteNonQuery(cmd)&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;'-- Get output via params&lt;br&gt;
&amp;nbsp;&amp;nbsp;'    Note that you might need to check for NULLs here too&lt;br&gt;
&amp;nbsp;&amp;nbsp;'    (I'm not here though)&lt;br&gt;
&amp;nbsp;&amp;nbsp;'    Vars declared outside of Using someplace....&lt;br&gt;
&amp;nbsp;&amp;nbsp;pcurid = CType(cmd.Parameters("@pcurid").Value, Integer)&lt;br&gt;
&amp;nbsp;&amp;nbsp;pcurname = Ctype(cmd.Parameters("@pcurname").Value, String)&lt;br&gt;
&amp;nbsp;&amp;nbsp;pcurrate = CType(cmd.Parameters("@pcurrate").Value, Decimal)&lt;br&gt;
End Using[/codesnippet]</description><pubDate>Tue, 07 Apr 2009 00:02:05 GMT</pubDate><dc:creator>Greg McGuffey</dc:creator></item></channel></rss>