Author |
Topic |
itchocks
Starting Member
44 Posts |
Posted - 2003-09-04 : 07:01:47
|
Hai All, Here i have a Serious problem. Without solving this scenario i can't implement my project. I am getting hanged because of this for a long time. I will explain the problem here Kindly view this issue and suggest me. Here i don't know how to attatch my Picture of Form and the Crystal Report 8.5 while it is in Design View , Runtime View, and the Report when hanging and the 8.5 Control pictures, i didn't attach with this mail . its Bmp files, If you have a Id give me i will send you the Bmp files. Kindly see and reply me. Without finishing this problem I can't implement this Project As you know. The database here is MsSql, I am only developing the front end in VB, I am using the Crystal Report 8.5 Control to show the Reports from vB The Issue Follows. The Report Hangs for the first time it shows only the blank screen, then the user need to close the Application Manually (i.e) through EndTask program. Then after closing the Application when tries for the Second time the Report is shown with the Data's correctly. All our clients are using WinXP. The Report shows for the Second time or third time and Further.The project is compiled in the machine where it is devoloped [Advanced 2000 Server] and also tested by changing the project to WinNt Server and installed VB6 there and compile the porject from there. Win2000 AdvancedServer or WinNT both are servers. While runnging the VB it shows the Report without any interuption, where as when i am running from the client system it hangs for the First time, some times hangs for first 2 times (Usually I compile the project and run the Setup file in the Client machine and then create the Shortcut of the exe for them)The Print Command Button in the Form contains the following Code.Private Sub Printe_Click() If optProduct.Value = True Then Call optPpwise ElseIf optItem.Value = True Then Call optPitemwise ElseIf optInvoice.Value = True Then Call optInvoice ElseIf optSlsmanwise.Value = True Then Call optPsalessum ElseIf optcsum.Value = True Then Call optPcsum ElseIf optPcustName.Value = True Then Call Pcustname ElseIf optCustdetail.Value = True Then Call optPcustdetail ElseIf optCust.Value = True Then Call optPcstwise ElseIf optcsumvalue.Value = True Then Call PCsumListbyValue Else MsgBox "Choose Option !", vbExclamation, "Option - Missing" End IfEnd Sub If the User Clicks the Invoicewise Option Button and press PrintButton then the following code will fire the Function optInvoice() code will execute. that is shown belowPrivate Function optInvoice()CrystalReport1.GroupSelectionFormula = ""Dim i As IntegerDim pfdt As DateDim ptdt As DateDim strsf As StringFor i = 1 To 25 CrystalReport1.Formulas(i) = ""Next ipfdt = txtpfrom.Textptdt = txtpto.TextIf Len(cmbPprod.Text) <= 0 Or cmbPprod.Text = "All" Then CrystalReport1.ReportFileName = App.Path & "\invoicewiseitemwgt.rpt" strsf = "{ST030100.ST03015} in Date(" & _ Format(pfdt, "YYYY,M,D") & ") to Date(" & _ Format(ptdt, "YYYY,M,D") & ")" CrystalReport1.ReplaceSelectionFormula (strsf) CrystalReport1.Formulas(1) = "fdt='" & Format(pfdt, "DD/MM/YYYY") & "'" CrystalReport1.Formulas(4) = "tdt='" & Format(ptdt, "DD/MM/YYYY") & "'" CrystalReport1.DiscardSavedData = True CrystalReport1.PrintReportElse CrystalReport1.ReportFileName = App.Path & "\invoicewiseitem.rpt" strsf = "{ST030100.ST03015} in Date(" & _ Format(pfdt, "YYYY,M,D") & ") to Date(" & _ Format(ptdt, "YYYY,M,D") & ")" CrystalReport1.ReplaceSelectionFormula (strsf) CrystalReport1.GroupSelectionFormula = "{ST030100.ST03018}='" & cmbPprod.Text & "'" CrystalReport1.Formulas(1) = "fdt='" & Format(pfdt, "DD/MM/YYYY") & "'" CrystalReport1.Formulas(4) = "tdt='" & Format(ptdt, "DD/MM/YYYY") & "'" CrystalReport1.DiscardSavedData = True CrystalReport1.PrintReportEnd IfEnd FunctionAs below in the FormLoad event I am connecting Crstal Report to Database Private Sub Form_Load()CrystalReport1.Connect = "DSN=scalaDB;UID=scala;PWD=scala"End SubI also check the Server Performance while the user clicks the Print Button to view the Report. The ODBC are properly configured in the Client machine and the Devoloped machine. Even the Report which has less Reports getting hanged sometimes.The Server is not loaded. Eventhough the CPU usage is 0% its hanging. Kindly consider this issue as impartant and reply me. my email id is itchocks@rediffmail.comThank you very much,Chock.Chock |
|
Stoad
Freaky Yak Linguist
1983 Posts |
Posted - 2003-09-04 : 09:46:51
|
MaybeCrystalReport1.ResetbeforeCrystalReport1.ReportFileName = |
|
|
itchocks
Starting Member
44 Posts |
Posted - 2003-09-04 : 10:49:04
|
Hai Stoad, I tested as you said. Then also its hanging in the client PC's.All the clients are having XP. It may be the reason what you said. But at first time it get's hanging. Actually at first time. The ReportFileName will how have only one Name then why it has to hang. Some suggested to Increase the cache memory and some suggested to check the ODBC. Porbably from where the problem will be.Kindly reply me.Thank you very much,Chock.Chock |
|
|
itchocks
Starting Member
44 Posts |
Posted - 2003-09-04 : 10:50:01
|
Hai Stoad, I tested as you said. Then also its hanging in the client PC's.All the clients are having XP. It may be the reason what you said. But at first time it get's hanging. Actually at first time. The ReportFileName will how have only one Name then why it has to hang. Some suggested to Increase the cache memory and some suggested to check the ODBC. Porbably from where the problem will be. At the second time its come very fast.Kindly reply me.Thank you very much,Chock.Chock |
|
|
Stoad
Freaky Yak Linguist
1983 Posts |
Posted - 2003-09-04 : 12:31:23
|
Oh, Chock... :(What if write it twice?CrystalReport1.ReportFileName = App.Path & "\invoicewiseitemwgt.rpt"CrystalReport1.ReportFileName = App.Path & "\invoicewiseitemwgt.rpt"Don't laugh! :) I know an MS control for which this trick helps. |
|
|
Stoad
Freaky Yak Linguist
1983 Posts |
Posted - 2003-09-04 : 12:44:47
|
Maybe a time delay (e.g. 1 sec) before printing could help?while ...doeventswendCrystalReport1.PrintReport |
|
|
itchocks
Starting Member
44 Posts |
Posted - 2003-09-05 : 03:52:46
|
Hai Stoad, Are you asking me to use the While Do Events instead of below If statement.If Len(cmbPprod.Text) <= 0 Or cmbPprod.Text = "All" ThenCrystalReport1.Reset = TrueCrystalReport1.ReportFileName = App.Path & "\invoicewiseitemwgt.rpt"strsf = "{ST030100.ST03015} in Date(" & _Format(pfdt, "YYYY,M,D") & ") to Date(" & _Format(ptdt, "YYYY,M,D") & ")"CrystalReport1.ReplaceSelectionFormula (strsf)CrystalReport1.Formulas(1) = "fdt='" & Format(pfdt, "DD/MM/YYYY") & "'"CrystalReport1.Formulas(4) = "tdt='" & Format(ptdt, "DD/MM/YYYY") & "'"CrystalReport1.DiscardSavedData = TrueCrystalReport1.PrintReportas belowWhile condition and DoEventsWendI think you say this. Ok I will try and tell you. Thank you for your response.Thank you very much,Chock.Chock |
|
|
Stoad
Freaky Yak Linguist
1983 Posts |
Posted - 2003-09-05 : 04:30:22
|
No!! I meant to insert a time delay before printing:CrystalReport1.DiscardSavedData = Truet=Timer()while Timer-t<=1doeventswendCrystalReport1.PrintReportAll your code lines must be left intact. |
|
|
itchocks
Starting Member
44 Posts |
Posted - 2003-09-06 : 07:43:16
|
Hai Stoad, Inserting a time delay means, i didn't use the DoEvents before in VB. Should i run any loop after CrystalReport1.DiscardSavedDate = True and before CrystalReport1.PrintReportWhat does the t = Timer() meansShoul i use timer control in the Form or whatif so what does the value i have to set to the Timer Controland what i have to give inside DoEventsWend.Kindl explain me how can i change my code.Thank you,Chock.Chock |
|
|
Stoad
Freaky Yak Linguist
1983 Posts |
Posted - 2003-09-06 : 09:23:22
|
Timer() is just a function not a control.It returns a Single representing the number of seconds elapsed since midnight.DoEvents() function yields execution so that the operating system can processother events.DoEvents passes control to the operating system. Control is returned after theoperating system has finished processing the events in its queue and all keys inthe SendKeys queue have been sent.So, t is just a variable. t=timer() ' here (for example) t=234566.23In the loop you just wait till Timer() value is 1 sec greater than that fixed in tvariable value. After that the loop finishes and CrystalReport1.PrintReportmethod is executed.Pity I can't warrant that this helps for sure but who knows.Anyway it will be a harmless try. |
|
|
itchocks
Starting Member
44 Posts |
Posted - 2003-09-06 : 12:47:30
|
Hai Stoad,So shall i try as belowDim t as variant If Len(cmbPprod.Text) <= 0 Or cmbPprod.Text = "All" ThenCrystalReport1.Reset = TrueCrystalReport1.ReportFileName = App.Path & "\invoicewiseitemwgt.rpt"strsf = "{ST030100.ST03015} in Date(" & _Format(pfdt, "YYYY,M,D") & ") to Date(" & _Format(ptdt, "YYYY,M,D") & ")"CrystalReport1.ReplaceSelectionFormula (strsf)CrystalReport1.Formulas(1) = "fdt='" & Format(pfdt, "DD/MM/YYYY") & "'"CrystalReport1.Formulas(4) = "tdt='" & Format(ptdt, "DD/MM/YYYY") & "'"CrystalReport1.DiscardSavedData = Truet=Timer()While Timer-t<=1DoEventsWendCrystalReport1.PrintReportshould i assign the values for any thing here or will the t = Timer()will have any default value.I have to declare t as variant or what.am i right with the above statment.Thank you,Chock.Chock |
|
|
Stoad
Freaky Yak Linguist
1983 Posts |
Posted - 2003-09-06 : 14:30:40
|
>am i right with the above statmentExactly. Try this. |
|
|
itchocks
Starting Member
44 Posts |
Posted - 2003-09-07 : 05:02:32
|
Hai , I tried the below as you said by using the DoEventsPrivate Function cinvoice() CrystalReport1.GroupSelectionFormula = "" Dim t As Variant Dim i As Integer Dim cfdt As Date Dim ctdt As Date Dim strsf As String For i = 1 To 25 CrystalReport1.Formulas(i) = "" Next i cfdt = txtCfrom.Text ctdt = txtCto.Text If Len(cmbCustomername.Text) <= 0 Or cmbCustomername.Text = "All" Then CrystalReport1.Reset CrystalReport1.WindowState = crptMaximized CrystalReport1.WindowShowPrintSetupBtn = True CrystalReport1.WindowShowRefreshBtn = True CrystalReport1.WindowShowSearchBtn = True CrystalReport1.WindowShowZoomCtl = True CrystalReport1.ReportFileName = App.Path & "\cinvoicewgt.rpt" strsf = "{ST030100.ST03015} in Date(" & _ Format(cfdt, "YYYY,M,D") & ") to Date (" & _ Format(ctdt, "YYYY,M,D") & ")" CrystalReport1.ReplaceSelectionFormula (strsf) CrystalReport1.Formulas(1) = "fdt='" & Format(cfdt, "DD/MM/YYYY") & "'" CrystalReport1.Formulas(4) = "tdt='" & Format(ctdt, "DD/MM/YYYY") & "'" CrystalReport1.DiscardSavedData = True t = Timer() While Timer - t <= 1 DoEvents Wend CrystalReport1.PrintReport Else CrystalReport1.Reset CrystalReport1.WindowState = crptMaximized CrystalReport1.WindowShowPrintSetupBtn = True CrystalReport1.WindowShowRefreshBtn = True CrystalReport1.WindowShowSearchBtn = True CrystalReport1.WindowShowZoomCtl = True CrystalReport1.ReportFileName = App.Path & "\cinvoice.rpt" strsf = "{ST030100.ST03015} in Date(" & _ Format(cfdt, "YYYY,M,D") & ") to Date(" & _ Format(ctdt, "YYYY,M,D") & ")" CrystalReport1.ReplaceSelectionFormula (strsf) CrystalReport1.GroupSelectionFormula = "{SL010100.SL01002}='" & Replace(cmbCustomername.Text, "'", "''") & "'" CrystalReport1.Formulas(1) = "fdt='" & Format(cfdt, "DD/MM/YYYY") & "'" CrystalReport1.Formulas(4) = "tdt='" & Format(ctdt, "DD/MM/YYYY") & "'" CrystalReport1.DiscardSavedData = True t = Timer() While Timer - t <= 1 DoEvents Wend CrystalReport1.PrintReport End If End FunctionStill its getting hanged for the first time. Kindly look at my connection string and suggest the way i am writing is correct or not and if you have any idea kindly suggest me.Thank you,Chock.Chock |
|
|
Stoad
Freaky Yak Linguist
1983 Posts |
Posted - 2003-09-07 : 08:09:56
|
Chock,try this connection string instead of "DSN=scalaDB;UID=scala;PWD=scala":"DRIVER={sql server};DSN=scalaDB;SERVER=;UID=scala;PWD=scala;"========================================In my scalaDB.dsn file I put only these three lines:[ODBC]DATABASE=myDBNameSERVER=mySQLServerName |
|
|
Stoad
Freaky Yak Linguist
1983 Posts |
Posted - 2003-09-07 : 08:36:03
|
Plus, if we assume that the root of the trouble lies in the connection failurefor the first time only, then what if we imitate the 2nd and the 3rd tryes toconnect by adding two spare lines in Sub Form_Load() code?Private Sub Form_Load()CrystalReport1.Connect = "DSN=scalaDB;UID=scala;PWD=scala"CrystalReport1.Connect = "DSN=scalaDB;UID=scala;PWD=scala"CrystalReport1.Connect = "DSN=scalaDB;UID=scala;PWD=scala"End Sub |
|
|
itchocks
Starting Member
44 Posts |
Posted - 2003-09-07 : 10:29:37
|
Hai, I tried as you said by adding the Driver to the Connection string. I dont know which is the correct one. All the below three are working in the Devolopment machine without error and also i compiled and install in the Client PC. Again it hangs. CrystalReport1.Connect = "DSN=scalaDB;UID=scala;PWD=scala"CrystalReport1.Connect = "DSN=scala;UID=sa;PWD=;DSQ=scalaDB"CrystalReport1.Connect = "DRIVER={SQLOLEDB.1};DSN=scalaDB;SERVER=scala;UID=scala;PWD=scala"Then i repeated the Connection string two times and tested as you saidPrivate Sub Form_Load()CrystalReport1.Connect = "DSN=scalaDB;UID=scala;PWD=scala"CrystalReport1.Connect = "DSN=scalaDB;UID=scala;PWD=scala"End Sub Now also its hanging while running the application by choosing it from the Start Menu. Which is placed there after running the Setup by default. Where as i create the shortcut of the application from the devolopment machine and while running through that, the report is showing correctly. I don't know which I should use. and the application is hanging when i run from the STart menu and its running when i go through the Shortcut.Thank you,Chock.Chock |
|
|
Stoad
Freaky Yak Linguist
1983 Posts |
Posted - 2003-09-07 : 13:40:27
|
'Fine'. Why did you add your 'corrections' into this:"DRIVER={sql server};DSN=scalaDB;SERVER=;UID=scala;PWD=scala;"???If I explicitly write into this string SERVER namethen I can't connect to this server!!!!!!!!!!!!!!!!!!!! |
|
|
Stoad
Freaky Yak Linguist
1983 Posts |
Posted - 2003-09-07 : 14:57:55
|
Seems you must forget for a while about CrystalReportand just check it without CrystalReport1.Connect:Private Sub Form_Load()' I commented next line' CrystalReport1.Connect = "DSN=scalaDB;UID=scala;PWD=scala"End SubIf it works fine then try to move CrystalReport1.Connect fromSub Form_Load() into Sub Form_Open(). |
|
|
Stoad
Freaky Yak Linguist
1983 Posts |
Posted - 2003-09-07 : 17:47:25
|
Maybe it is better to remove CrystalReport1.Connect fromthe initial form events and to place it right after Sub Printe_Click()? |
|
|
Stoad
Freaky Yak Linguist
1983 Posts |
Posted - 2003-09-07 : 19:16:14
|
How about this before printing:CrystalReport1.Destination = crptToPrinterthenCrystalReport1.Action = 1(this line is instead of ret=CrystalReport1.PrintReport)Secondly, in most codes that I've seen CrystalReport1.ReportFileNamepreceeds CrystalReport1.Connect. Maybe it matters? |
|
|
itchocks
Starting Member
44 Posts |
Posted - 2003-09-08 : 11:12:58
|
Hai Stoad, I removed the connection string from the form. In that form I am using nearly 52 Reports. Only at one place it says Cannot Open sql server. Then only for that function i place the connection string as belowCrystalReport1.Connect = "DSN=scalaDB;UID=scala;PWD=scala"then that report also works. Now I compiled and tested. It works fine. But it should continue working. If this too doesn't works then i have to try by giving the connection string after Assinging the ReportFileName inside the Function.Thank you very much,Chock.Chock |
|
|
Next Page
|