Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

example please? Stored procedure in Winform returning data.

5 posts in General Discussion Last posting was on 2008-03-04 14:38:55.0Z
Andy<<cowboy>>Stapleton Posted on 2008-02-28 21:11:52.0Z
From: "Andy<<cowboy>>Stapleton" <ccscowboy@ccscowboy.com>
Newsgroups: ianywhere.public.general
Subject: example please? Stored procedure in Winform returning data.
Lines: 64
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <47c72398@forums-1-dub>
Date: 28 Feb 2008 13:11:52 -0800
X-Trace: forums-1-dub 1204233112 10.22.241.152 (28 Feb 2008 13:11:52 -0800)
X-Original-Trace: 28 Feb 2008 13:11:52 -0800, vip152.sybase.com
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:6726
Article PK: 4973

I am using a stored procedure to return some data to a winform in vs2008,
and even though I get data back from the SP , I am not getting it inside the
form,(reader is not returning the record).

I must be doing something wrong, here is the code, if someone has a
solution, I would appreciate it.. thanks.
SAConnection ttStatsConn = new SAConnection("Data
Source=Forexmgr;UID=DBA;PWD=Sql");

try

{

ttStatsConn.Open();

SACommand cmd = new SACommand("Call Dba.CalcPortFolio()", ttStatsConn);

cmd.

SADataReader reader = cmd.ExecuteReader();

while (reader.Read())

{

txtGrossProfit.Text = Convert.ToString(reader.GetDecimal(0));

txtGrossLoss.Text = Convert.ToString(reader.GetDecimal(1));

txtNetProfitloss.Text = Convert.ToString(reader.GetDecimal(2));

txtAvgProfit.Text = Convert.ToString(reader.GetDecimal(3));

txtAvgLoss.Text = Convert.ToString(reader.GetDecimal(4));

txtWinTrades.Text = Convert.ToString(reader.GetInt32(5));

txtWinTrades.Text = Convert.ToString(reader.GetInt32(6));

}

reader.Close();

ttStatsConn.Close();

}

catch (SAException ex)

{

MessageBox.Show(ex.Errors[0].Message);

}




--
Andy <<Cowboy>> Stapleton
www.forexmgr.com
www.BlueCollarTradingSociety.com


Jeff Albion (Sybase iAnywhere) Posted on 2008-02-29 14:41:13.0Z
From: "Jeff Albion (Sybase iAnywhere)" <firstname.lastname@ianywhere.com>
User-Agent: Thunderbird 2.0.0.12 (Windows/20080213)
MIME-Version: 1.0
Newsgroups: ianywhere.public.general
Subject: Re: example please? Stored procedure in Winform returning data.
References: <47c72398@forums-1-dub>
In-Reply-To: <47c72398@forums-1-dub>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <47c81989$1@forums-1-dub>
Date: 29 Feb 2008 06:41:13 -0800
X-Trace: forums-1-dub 1204296073 10.22.241.152 (29 Feb 2008 06:41:13 -0800)
X-Original-Trace: 29 Feb 2008 06:41:13 -0800, vip152.sybase.com
Lines: 23
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:6729
Article PK: 4971

Andy,

1. Which version of SQL Anywhere is this? (dbsrv10 -v)
2. What's the SP definition for "Dba.CalcPortFolio()" ?

Regards,

Andy<<cowboy>>Stapleton wrote:
> I am using a stored procedure to return some data to a winform in vs2008,
> and even though I get data back from the SP , I am not getting it inside the
> form,(reader is not returning the record).
>
> I must be doing something wrong, here is the code, if someone has a
> solution, I would appreciate it.. thanks.

--
Jeff Albion, Product Support Analyst
Sybase iAnywhere

iAnywhere Developer Community : http://www.ianywhere.com/developer
iAnywhere Documentation : http://www.ianywhere.com/developer/product_manuals
ASA Patches and EBFs :
http://downloads.sybase.com/swd/summary.do?baseprod=144&client=ianywhere&timeframe=0


Andy<<cowboy>>Stapleton Posted on 2008-03-01 18:32:27.0Z
From: "Andy<<cowboy>>Stapleton" <ccscowboy@ccscowboy.com>
Newsgroups: ianywhere.public.general
References: <47c72398@forums-1-dub> <47c81989$1@forums-1-dub>
Subject: Re: example please? Stored procedure in Winform returning data.
Lines: 100
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-Mimeole: Produced By Microsoft MimeOLE V6.00.2900.3198
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <47c9a13b@forums-1-dub>
Date: 1 Mar 2008 10:32:27 -0800
X-Trace: forums-1-dub 1204396347 10.22.241.152 (1 Mar 2008 10:32:27 -0800)
X-Original-Trace: 1 Mar 2008 10:32:27 -0800, vip152.sybase.com
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:6730
Article PK: 4974

version 10, I have also added the resutls line with no difference.

create PROCEDURE "DBA"."CalcPortfolio"()

BEGIN
/*
calculate the figures needed for max draw down, and other information for
each month
*/
Declare Local Temporary Table results(
Year integer,
Month integer,
Monthname varchar(20),
MaxDrawdown decimal(12,2),
GrossProfit decimal(12,2),
GrossLoss Decimal(12,2),
TradeCount integer,
TradeCountGain integer,
TradeCountLoss integer,
NetProfit decimal(12,2),
AverageProfit Decimal(12,2),
AverageLoss Decimal(12,2));


Insert into Results(year,Month,MonthName)
Select Distinct Year(ExitDate),MONTH(ExitDate),MonthName(ExitDate) from
Dba.TradeTransactions;

Update Results
Set GrossProfit = (select Sum(DepositAmt/Lots) from
Dba.TradeTransactions
where Month(Exitdate) = Month
and Year(ExitDate) = Year
and (orderno != 1 or OrderNo is null)
and Depositamt > 0);

Update Results
Set GrossLoss = (select Sum(DepositAmt/Lots) from Dba.TradeTransactions
where Month(Exitdate) = Month
and Year(ExitDate) = Year
and (orderno != 1 or OrderNo is null)
and DepositAmt < 0);

Update Results
Set TradeCount = (select Count(*) from Dba.TradeTransactions
where Month(Exitdate) = Month
and (orderno !=1 or OrderNo is null)
and Year(ExitDate) = Year);
Update Results
Set TradeCountGain = (select Count(*) from Dba.TradeTransactions
where Month(Exitdate) = Month
and DepositAmt > 0
and (orderno !=1 or OrderNo is null)
and Year(ExitDate) = Year);
Update Results
Set TradeCountLoss = (select Count(*) from Dba.TradeTransactions
where Month(Exitdate) = Month
and DepositAmt < 0
and (orderno !=1 or OrderNo is null)
and Year(ExitDate) = Year);

Update Results
Set NetProfit = GrossProfit + GrossLoss,
AverageProfit = GrossProfit / TradeCount,
AverageLoss = GrossLoss / TradeCount;



select * from Results order by year,month;

END

"Jeff Albion (Sybase iAnywhere)" <firstname.lastname@ianywhere.com> wrote in
message news:47c81989$1@forums-1-dub...
> Andy,
>
> 1. Which version of SQL Anywhere is this? (dbsrv10 -v)
> 2. What's the SP definition for "Dba.CalcPortFolio()" ?
>
> Regards,
>
> Andy<<cowboy>>Stapleton wrote:
>> I am using a stored procedure to return some data to a winform in vs2008,
>> and even though I get data back from the SP , I am not getting it inside
>> the form,(reader is not returning the record).
>>
>> I must be doing something wrong, here is the code, if someone has a
>> solution, I would appreciate it.. thanks.
>
> --
> Jeff Albion, Product Support Analyst
> Sybase iAnywhere
>
> iAnywhere Developer Community : http://www.ianywhere.com/developer
> iAnywhere Documentation :
> http://www.ianywhere.com/developer/product_manuals
> ASA Patches and EBFs :
> http://downloads.sybase.com/swd/summary.do?baseprod=144&client=ianywhere&timeframe=0


Jeff Albion (Sybase iAnywhere) Posted on 2008-03-03 15:57:31.0Z
From: "Jeff Albion (Sybase iAnywhere)" <firstname.lastname@ianywhere.com>
User-Agent: Thunderbird 2.0.0.12 (Windows/20080213)
MIME-Version: 1.0
Newsgroups: ianywhere.public.general
Subject: Re: example please? Stored procedure in Winform returning data.
References: <47c72398@forums-1-dub> <47c81989$1@forums-1-dub> <47c9a13b@forums-1-dub>
In-Reply-To: <47c9a13b@forums-1-dub>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <47cc1feb$1@forums-1-dub>
Date: 3 Mar 2008 07:57:31 -0800
X-Trace: forums-1-dub 1204559851 10.22.241.152 (3 Mar 2008 07:57:31 -0800)
X-Original-Trace: 3 Mar 2008 07:57:31 -0800, vip152.sybase.com
Lines: 140
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:6736
Article PK: 4980

Andy,

Andy<<cowboy>>Stapleton wrote:
> version 10, I have also added the resutls line with no difference.

Did it look like the following?

===========
create PROCEDURE "DBA"."CalcPortfolio"()
RESULT (
Year integer,
Month integer,
Monthname varchar(20),
MaxDrawdown decimal(12,2),
GrossProfit decimal(12,2),
GrossLoss Decimal(12,2),
TradeCount integer,
TradeCountGain integer,
TradeCountLoss integer,
NetProfit decimal(12,2),
AverageProfit Decimal(12,2),
AverageLoss Decimal(12,2) )
BEGIN
DECLARE LOCAL TEMPORARY TABLE results ( ...
...
SELECT * FROM results;
END;
===========

If not, try it and see if it's working correctly.

Regards,

>
> create PROCEDURE "DBA"."CalcPortfolio"()
>
> BEGIN
> /*
> calculate the figures needed for max draw down, and other information for
> each month
> */
> Declare Local Temporary Table results(
> Year integer,
> Month integer,
> Monthname varchar(20),
> MaxDrawdown decimal(12,2),
> GrossProfit decimal(12,2),
> GrossLoss Decimal(12,2),
> TradeCount integer,
> TradeCountGain integer,
> TradeCountLoss integer,
> NetProfit decimal(12,2),
> AverageProfit Decimal(12,2),
> AverageLoss Decimal(12,2));
>
>
> Insert into Results(year,Month,MonthName)
> Select Distinct Year(ExitDate),MONTH(ExitDate),MonthName(ExitDate) from
> Dba.TradeTransactions;
>
> Update Results
> Set GrossProfit = (select Sum(DepositAmt/Lots) from
> Dba.TradeTransactions
> where Month(Exitdate) = Month
> and Year(ExitDate) = Year
> and (orderno != 1 or OrderNo is null)
> and Depositamt > 0);
>
> Update Results
> Set GrossLoss = (select Sum(DepositAmt/Lots) from Dba.TradeTransactions
> where Month(Exitdate) = Month
> and Year(ExitDate) = Year
> and (orderno != 1 or OrderNo is null)
> and DepositAmt < 0);
>
> Update Results
> Set TradeCount = (select Count(*) from Dba.TradeTransactions
> where Month(Exitdate) = Month
> and (orderno !=1 or OrderNo is null)
> and Year(ExitDate) = Year);
> Update Results
> Set TradeCountGain = (select Count(*) from Dba.TradeTransactions
> where Month(Exitdate) = Month
> and DepositAmt > 0
> and (orderno !=1 or OrderNo is null)
> and Year(ExitDate) = Year);
> Update Results
> Set TradeCountLoss = (select Count(*) from Dba.TradeTransactions
> where Month(Exitdate) = Month
> and DepositAmt < 0
> and (orderno !=1 or OrderNo is null)
> and Year(ExitDate) = Year);
>
> Update Results
> Set NetProfit = GrossProfit + GrossLoss,
> AverageProfit = GrossProfit / TradeCount,
> AverageLoss = GrossLoss / TradeCount;
>
>
>
> select * from Results order by year,month;
>
> END
>
> "Jeff Albion (Sybase iAnywhere)" <firstname.lastname@ianywhere.com> wrote in
> message news:47c81989$1@forums-1-dub...
>> Andy,
>>
>> 1. Which version of SQL Anywhere is this? (dbsrv10 -v)
>> 2. What's the SP definition for "Dba.CalcPortFolio()" ?
>>
>> Regards,
>>
>> Andy<<cowboy>>Stapleton wrote:
>>> I am using a stored procedure to return some data to a winform in vs2008,
>>> and even though I get data back from the SP , I am not getting it inside
>>> the form,(reader is not returning the record).
>>>
>>> I must be doing something wrong, here is the code, if someone has a
>>> solution, I would appreciate it.. thanks.
>> --
>> Jeff Albion, Product Support Analyst
>> Sybase iAnywhere
>>
>> iAnywhere Developer Community : http://www.ianywhere.com/developer
>> iAnywhere Documentation :
>> http://www.ianywhere.com/developer/product_manuals
>> ASA Patches and EBFs :
>> http://downloads.sybase.com/swd/summary.do?baseprod=144&client=ianywhere&timeframe=0
>
>

--
Jeff Albion, Product Support Analyst
Sybase iAnywhere

iAnywhere Developer Community : http://www.ianywhere.com/developer
iAnywhere Documentation : http://www.ianywhere.com/developer/product_manuals
ASA Patches and EBFs :
http://downloads.sybase.com/swd/summary.do?baseprod=144&client=ianywhere&timeframe=0


Andy<<cowboy>>Stapleton Posted on 2008-03-04 14:38:55.0Z
From: "Andy<<cowboy>>Stapleton" <ccscowboy@ccscowboy.com>
Newsgroups: ianywhere.public.general
References: <47c72398@forums-1-dub> <47c81989$1@forums-1-dub> <47c9a13b@forums-1-dub> <47cc1feb$1@forums-1-dub>
Subject: Re: example please? Stored procedure in Winform returning data.
Lines: 160
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <47cd5eff$1@forums-1-dub>
Date: 4 Mar 2008 06:38:55 -0800
X-Trace: forums-1-dub 1204641535 10.22.241.152 (4 Mar 2008 06:38:55 -0800)
X-Original-Trace: 4 Mar 2008 06:38:55 -0800, vip152.sybase.com
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:6739
Article PK: 4984

yes, I have been writing SP for 10 years(since watcom days)...<g>.... it
just seemed strange not to work. for now, I changed to store in a table on
a monthly basis and retrieve from there. but later I will try again.


--
Andy <<Cowboy>> Stapleton
www.forexmgr.com
www.BlueCollarTradingSociety.com

"Jeff Albion (Sybase iAnywhere)" <firstname.lastname@ianywhere.com> wrote in
message news:47cc1feb$1@forums-1-dub...
> Andy,
>
> Andy<<cowboy>>Stapleton wrote:
>> version 10, I have also added the resutls line with no difference.
>
> Did it look like the following?
>
> ===========
> create PROCEDURE "DBA"."CalcPortfolio"()
> RESULT (
> Year integer,
> Month integer,
> Monthname varchar(20),
> MaxDrawdown decimal(12,2),
> GrossProfit decimal(12,2),
> GrossLoss Decimal(12,2),
> TradeCount integer,
> TradeCountGain integer,
> TradeCountLoss integer,
> NetProfit decimal(12,2),
> AverageProfit Decimal(12,2),
> AverageLoss Decimal(12,2) )
> BEGIN
> DECLARE LOCAL TEMPORARY TABLE results ( ...
> ...
> SELECT * FROM results;
> END;
> ===========
>
> If not, try it and see if it's working correctly.
>
> Regards,
>
>>
>> create PROCEDURE "DBA"."CalcPortfolio"()
>>
>> BEGIN
>> /*
>> calculate the figures needed for max draw down, and other information
>> for each month
>> */
>> Declare Local Temporary Table results(
>> Year integer,
>> Month integer,
>> Monthname varchar(20),
>> MaxDrawdown decimal(12,2),
>> GrossProfit decimal(12,2),
>> GrossLoss Decimal(12,2),
>> TradeCount integer,
>> TradeCountGain integer,
>> TradeCountLoss integer,
>> NetProfit decimal(12,2),
>> AverageProfit Decimal(12,2),
>> AverageLoss Decimal(12,2));
>>
>>
>> Insert into Results(year,Month,MonthName)
>> Select Distinct Year(ExitDate),MONTH(ExitDate),MonthName(ExitDate)
>> from Dba.TradeTransactions;
>>
>> Update Results
>> Set GrossProfit = (select Sum(DepositAmt/Lots) from
>> Dba.TradeTransactions
>> where Month(Exitdate) = Month
>> and Year(ExitDate) = Year
>> and (orderno != 1 or OrderNo is null)
>> and Depositamt > 0);
>>
>> Update Results
>> Set GrossLoss = (select Sum(DepositAmt/Lots) from
>> Dba.TradeTransactions
>> where Month(Exitdate) = Month
>> and Year(ExitDate) = Year
>> and (orderno != 1 or OrderNo is null)
>> and DepositAmt < 0);
>>
>> Update Results
>> Set TradeCount = (select Count(*) from Dba.TradeTransactions
>> where Month(Exitdate) = Month
>> and (orderno !=1 or OrderNo is null)
>> and Year(ExitDate) = Year);
>> Update Results
>> Set TradeCountGain = (select Count(*) from Dba.TradeTransactions
>> where Month(Exitdate) = Month
>> and DepositAmt > 0
>> and (orderno !=1 or OrderNo is null)
>> and Year(ExitDate) = Year);
>> Update Results
>> Set TradeCountLoss = (select Count(*) from Dba.TradeTransactions
>> where Month(Exitdate) = Month
>> and DepositAmt < 0
>> and (orderno !=1 or OrderNo is null)
>> and Year(ExitDate) = Year);
>>
>> Update Results
>> Set NetProfit = GrossProfit + GrossLoss,
>> AverageProfit = GrossProfit / TradeCount,
>> AverageLoss = GrossLoss / TradeCount;
>>
>>
>>
>> select * from Results order by year,month;
>>
>> END
>>
>> "Jeff Albion (Sybase iAnywhere)" <firstname.lastname@ianywhere.com> wrote
>> in message news:47c81989$1@forums-1-dub...
>>> Andy,
>>>
>>> 1. Which version of SQL Anywhere is this? (dbsrv10 -v)
>>> 2. What's the SP definition for "Dba.CalcPortFolio()" ?
>>>
>>> Regards,
>>>
>>> Andy<<cowboy>>Stapleton wrote:
>>>> I am using a stored procedure to return some data to a winform in
>>>> vs2008, and even though I get data back from the SP , I am not getting
>>>> it inside the form,(reader is not returning the record).
>>>>
>>>> I must be doing something wrong, here is the code, if someone has a
>>>> solution, I would appreciate it.. thanks.
>>> --
>>> Jeff Albion, Product Support Analyst
>>> Sybase iAnywhere
>>>
>>> iAnywhere Developer Community : http://www.ianywhere.com/developer
>>> iAnywhere Documentation :
>>> http://www.ianywhere.com/developer/product_manuals
>>> ASA Patches and EBFs :
>>> http://downloads.sybase.com/swd/summary.do?baseprod=144&client=ianywhere&timeframe=0
>>
>>
>
> --
> Jeff Albion, Product Support Analyst
> Sybase iAnywhere
>
> iAnywhere Developer Community : http://www.ianywhere.com/developer
> iAnywhere Documentation :
> http://www.ianywhere.com/developer/product_manuals
> ASA Patches and EBFs :
> http://downloads.sybase.com/swd/summary.do?baseprod=144&client=ianywhere&timeframe=0