How to disconnect SQL client connection once crystal report is closed - sql

I'm currently using SAP Crystal Report 2013. I have a ODBC(RDO) connection setup and every time I run the Crystal Report from my native application(Progress 4GL Application), a new SQL DB connection gets established. However on closing the report, the SQL Client is not disconnected (i.e the connection still remains). Every time I open a report a new connection is established and it never disconnects until I close the application.
I tried using the .close() , .dispose() in VB.net code on which my Crystal Report is setup. Nothings seems to help.
Please Advise.

You can use
repo.Database.Dispose();

Related

Pentaho - Reconnect option when connection is not stable

I use Pentaho to migrate data from SQL server to MySQL. Unfortunately, the connection to MySQL is not stable and it sometimes failed in the middle.
Is there any option in Pentaho that allow Reconnect to MySQL when the package lost connection then the Pentaho package can continue running.
Thanks,
Try creating the DB connection using the wizard rather than using the new button.
I am using a share connection, so I just select connection name in the "Connection"
I applied a work around to by pass this case. That is auto retry logic which include a loop if ERROR and still have data then I go back some steps.

VB.Net Window Programming database coonection open close

I am working on a window project using VB.net. On every form of my project I opened Microsoft access database connection on form load and closed on form closing event. So I want to ask that this is good practice to open/close database connection on every form.
Consider the followings:
Would the db connection be used to update or only query?
How many users would open the form and connect to db at the same time?
If the users are many and they update db, I think it's not a good idea to keep connected while opening the form. Usually you may query some data upon opening and then close the connection immediately, and the same for updating.
It is good practice to create/open/close db connection every time you execute some query.
Notice that by create/open/close I mean instantiating new instance of SqlConnection.
Under the hood ADO.NET will open real, physical connection to the database server only once and re-use it every time you will open new connection by your code.
So every query should be execute with own new connection
Using connection As SqlConnection = new SqlConnection(yourConnectionString)
Using command As SqlCommand = new SqlCommand(sqlQuery, connection)
return command.ExecuteNonQuery();
End Using
End Using
If you open connection in Form_Load and close it in Form_Closing it possible that when exception thrown while form is opened your connection will remain opened.
By reducing amount of time when connection is "opened" in your code you can handle this situation by using Using keyword and avoid using of "ugly" try .. catch everywhere
And I hope you are using sql parameters (SqlParameter) in your queries.

The client driver attempted to recover the connection one or more times and all attempts failed

I'm developing an asp.net web application and using SQL express database in my application so every time when start the visual studio and insert the data by writing query i got this error.
The connection is broken and recovery is not possible. The client driver attempted to recover the connection one or more times and all attempts failed. Increase the value of ConnectRetryCount to increase the number of recovery attempts
any help will be greatly appreciated thanks!

Connecting crystal reports to oracle database using vb.net code

I'm using crystal reports 9, visual studio 2008, and oracle 9i in this project I'm doing. My crystal reports pull data from an oracle database, and are displayed on a CrystalReportViewer on a windows form. How would I make this connection using vb.net code?
Imagine this little scenario:
The host name for the oracle server is myHost.
The database name is myData
The username is myUser
The password is myPass.
Please assist me with the code to make this connection.
Your help will be highly appreciated.
Basically, you have a few options. If you've created a connection inside of the Crystal Report then you can hand off different login credentials to the report and crystal will handle it. You have to do it in a specific way through or it won't work (it's very picky on the order in which it's done). You will loop through the report and all the sub reports handing off new crendentials. The second route is to use a DataTable as your DataSource, populate it via VB.Net and hand it off (this doesn't sound like the route you're wanting to go).
Here are two blog entries where I describe how to pass new login credentials off to Crystal.
https://www.blakepell.com/2010-09-17-crystal-reports-changing-the-database-connection-from-net-subreport-links-and-the-case-of-the-missing-parameter-values
https://www.blakepell.com/2012-05-22-crystal-reports-extension-methods
In the first blog entry there is a "Private Sub ApplyNewServer(ByVal report As ReportDocument)" that will show you how to pass your new login and server information. It was extracted from another class so it might need slight modification to reference the login parameters you want to pass in.
Best of luck. ;)

Connecting to Crystal Reports 4.6 from VB

How can I connect to a Crystal Reports 4.6 report that connects to SQL Server 2005 as a data source, using Visual Basic?
I don't want to specify the connection string in the report. I want to pass the connection from VB. Is there any way to do this?
A long time ago I worked on Crystal 4.5 (I don't remember a 4.6). The way to change the connection details is still pretty much like it is today - Find the tables collection for each report and set the location & log on information for each one. Sub reports were a pain though. You had to go through each section of the report to find out if it contained a subreport, then get its table collection.