PDA

Click to See Complete Forum and Search --> : Datareport Grouping Problem


jobs_arghya
Dec 14th, 2007, 12:57 AM
Hi all

Hope to hear you fine both mentally and physically

Here is a new problem for you:

I am creating an inventory software. The software requires to keep track of all transactions of each fiscal year. Now I am creating database named as 2007-2008.mdb for fiscal year 2007-2008, 2006-2007.mdb for fiscal year 2006-2007 etc. The database contains the fields like stockgroup,stockitem, qty etc.

Suppose the user wants to know the transactions done in the year 2006-2007group by stockgroup. So I need to connect my dataenvironment to the database 2006-2007 which I am doing thru the code :

DataEnvironment1.ConnectionString"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\" & Trim(ipAddr) & "\BCRSTUDENT\" & Trim(fold) & Trim("\") & Trim(fold) & ".mdb;Persist Security Info=False"
DataEnvironment1.Connection1.Open
DataEnvironment1.rsCommand1_Grouping.Open "SHAPE {select * from stock } AS Command1 COMPUTE Command1 BY 'stockgroup'"
DataEnvironment1.rsCommand1_Grouping.Requery
DataReport1.Show

ipaddr is the ip address of the server where the database is locatedcentrally. and fold is tracking which fiscal year i.e fold may be 2006-2007 or 2007-2008 or like that

Now when I am showing the report for the first time it is fine.

in the QueryClose event of the DataReport i am using the code :
DataEnvironment1.Connection1.Close

When I am trying to show the record second time I am getting the Run Time Error '3709' stating

"This connection cannot be used to perform the operation. It is either closed or invalid in this context"

Can u help me out regarding this problem
Please help me

Thanx in advance

Regards
Arghya

wes4dbt
Dec 14th, 2007, 02:01 PM
Do you have to close the connection? Why not close the rsCommand1_Grouping

if rsCommand1_Grouping.State = adStateOpen then rsCommand1_Grouping.Close
DataEnvironment1.rsCommand1_Grouping.Open "SHAPE {select * from stock } AS Command1 COMPUTE Command1 BY 'stockgroup'"
DataEnvironment1.rsCommand1_Grouping.Requery
DataReport1.Show

You can set the connectionstring in the dataenviroment_initialize event