Connecting to database on 64 bit server via ODBC and .NET

Posted by newport1 on 19-Dec-2013 10:03

Hi,

I have a 64 bit server with OpenEdge 11.2 installed and I have created a program that will view Crystal Report files.

Posted by Wouter Dupré on 20-Feb-2014 01:53

I'm not sure if I'm completely with you, but if you're looking for a 64-bit ODBC driver for OpenEdge, I can tell you that it does exist. It's just not shipped by default with the product. However you can download it from the Electronic Download Center, free of charge.

When you go to ESD, you can find it following this path:

1. From the product list select 'Progress OpenEdge'

2. Choose your version of OpenEdge, in your case Progress OpenEdge 11.2.x

3. Choose SQL Client Access

4. Read and Accept the License Agreement :-)

5. Choose your platform to download the driver you need.

The keys are on the same page.

HTH,

Wouter

All Replies

Posted by newport1 on 19-Dec-2013 10:13

Please cancel the previous post since I made a mistake. Sorry, first time posting...

I have a 64 bit server with OpenEdge 11.2 installed and I have created a program that will open and display a Crystal Report.

The program loads the report and changes all the info in the report so it will connect to the proper server. I use a DSN for that but somehow it will not allow me to connect. The software is 32 bit so I will have to use the 32 bit odbc administrator to check for available drivers. Somehow the program is unable to connect and will give an "invalid argument given" error. When I change the connection settings to connect to an SQL server I have no issue. The SQL server ODBC driver is available for 64 bit but the 32 bit OpenEdge driver is not. Could this be a reason?

According to http://knowledgebase.progress.com/articles/Article/P97292 I need to look in the registry for the available ODBC drivers in HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBCINST.INI but this is the available list for 64 bit and not 32 bit. Will OpenEdge see the 32 bit drivers and if so, how can I make my program work?

I've attached my code.

Thanks

Posted by adisney on 19-Dec-2013 11:59

Sorry that I can't answer your question, but we're also struggling with trying to get Crystal 13+ to work with OpenEdge 11.2. How do you get the first line to even compile?  Assume you have a "using" statement prior ...

Any help/hints would be appreciated!

Posted by newport1 on 20-Dec-2013 01:49

You will need some steps for that:

* Use the Developer studio and not the AppBuilder. For me it never worked fine with Crystal

* Download the Crystal Reports for Visual Studio Redistributable (scn.sap.com/.../DOC-7824)

* Add the correct libraries to the assemblies. I use the following: CrystalDecisions.CrystalReports.Engine, CrystalDecisions.ReportAppServer.DataDefModel, CrystalDecisions.Windows.Forms

Now you should be able to compile the program.

There is a lot you can find on the internet but most is vb.net and it is not a matter of copy+paste unfortunately.

So I am stuck now at the last part :-(

Posted by newport1 on 17-Feb-2014 09:50

I never answered in this post since I've been too busy with a lot of projects but I finally asked a developer to take a look at it and he was very helpful and came up with an answer. Here is the code that should work (at least it works for us).

Note that the code below is just a snippet of my complete code. The rest however is default code for some forms/buttons/etc so not necessary for the example. I hope it will help anyone who is struggling with Crystal Reports:

/* Parameters Definitions */

/* Local Variable Definitions */

DEFINE VARIABLE crystalReportViewer1 AS CrystalDecisions.Windows.Forms.CrystalReportViewer NO-UNDO.

DEFINE VARIABLE FormObjectRef AS CLASS Progress.Windows.Form NO-UNDO.

DEFINE VARIABLE crwReport AS CrystalDecisions.CrystalReports.Engine.ReportDocument NO-UNDO.

DEFINE VARIABLE tblLogonInfo AS CrystalDecisions.Shared.TableLogOnInfo NO-UNDO.

DEFINE VARIABLE crRptTable AS CrystalDecisions.CrystalReports.Engine.Table NO-UNDO.

DEFINE VARIABLE OKpressed AS LOGICAL NO-UNDO INITIAL FALSE.

/* Connection variables */

DEFINE VARIABLE lv-DSN AS CHARACTER NO-UNDO.

DEFINE VARIABLE lv-odbc AS CHARACTER INIT "Progress OpenEdge 11.2 Driver" NO-UNDO.

DEFINE VARIABLE lv-Server AS CHARACTER INIT "servername"  NO-UNDO. /* Name of the server */

DEFINE VARIABLE lv-dbname AS CHARACTER INIT "dbname"  NO-UNDO. /* Name of the database */

DEFINE VARIABLE lv-User AS CHARACTER INIT "username"   NO-UNDO. /* Username */

DEFINE VARIABLE lv-Pass AS CHARACTER INIT "password"  NO-UNDO. /* Password */

DEFINE VARIABLE lv-Port AS CHARACTER INIT "port"  NO-UNDO. /* Port */

       FormObjectRef = NEW Progress.Windows.Form().        

       CrystalReportViewer1 = NEW CrystalDecisions.Windows.Forms.CrystalReportViewer().

       crwReport = NEW CrystalDecisions.CrystalReports.Engine.ReportDocument().      

       crwReport:Load(fiReportLocation:SCREEN-VALUE).

       /*crwReport:Load("name_of_report_to_load").*/

       FormObjectRef:Controls:Add(crystalReportViewer1).

       FormObjectRef:Size = NEW System.Drawing.Size(820, 520).

       /* Create an DSN */

       lv-dsn = "DRIVER=" + lv-odbc + ";HOST=" + lv-Server + ";PORT=" + lv-Port + ";DB=" + lv-dbname + ";UID=" + lv-user + ";PWD=" + lv-Pass.

       /* Based on code from msdn.microsoft.com/.../ms226184(v=vs.80).aspx */

       /* Removed reference to DatabaseName property - is covered by DB in lv-dsn and, if set, ODBC driver complains about duplicated parameter and connection fails */

       crwReport:SetDatabaseLogon(lv-User, lv-Pass).

       DO i = 0 TO crwReport:Database:Tables:Count - 1:

           crRptTable = crwReport:Database:Tables[i].

           tblLogonInfo = crRptTable:LogOnInfo.

           tblLogonInfo:ConnectionInfo:ServerName = lv-dsn.

           tblLogonInfo:ConnectionInfo:UserID = lv-User.

           tblLogonInfo:ConnectionInfo:Password = lv-Pass.

           crRptTable:ApplyLogOnInfo(tblLogonInfo).

       END.  

       crystalReportViewer1:ActiveViewIndex = -1.

       crystalReportViewer1:BorderStyle = System.Windows.Forms.BorderStyle:FixedSingle.

       crystalReportViewer1:Cursor = System.Windows.Forms.Cursors:Default.

       crystalReportViewer1:Dock = System.Windows.Forms.DockStyle:Fill.

       crystalReportViewer1:Location = NEW System.Drawing.Point(0, 0).

       crystalReportViewer1:Name = "crystalReportViewer1".

       crystalReportViewer1:Size = NEW System.Drawing.Size(300, 300).

       crystalReportViewer1:TabIndex = 0.

       crystalReportViewer1:AutoScaleDimensions = NEW System.Drawing.SizeF(Progress.Util.CastUtil:ToSingle(6), Progress.Util.CastUtil:ToSingle(13)).

       crystalReportViewer1:AutoSize = TRUE.

       crystalReportViewer1:BackColor = System.Drawing.SystemColors:Desktop.

       crystalReportViewer1:ReportSource = crwReport.

       crystalReportViewer1:ResumeLayout(FALSE).

       crystalReportViewer1:RefreshReport().

       FormObjectRef:StartPosition = System.Windows.Forms.FormStartPosition:CenterScreen.

       FormObjectRef:Text = "Crystal Report Viewer".

       WAIT-FOR FormObjectRef:ShowDialog().

Posted by Wouter Dupré on 20-Feb-2014 01:53

I'm not sure if I'm completely with you, but if you're looking for a 64-bit ODBC driver for OpenEdge, I can tell you that it does exist. It's just not shipped by default with the product. However you can download it from the Electronic Download Center, free of charge.

When you go to ESD, you can find it following this path:

1. From the product list select 'Progress OpenEdge'

2. Choose your version of OpenEdge, in your case Progress OpenEdge 11.2.x

3. Choose SQL Client Access

4. Read and Accept the License Agreement :-)

5. Choose your platform to download the driver you need.

The keys are on the same page.

HTH,

Wouter

Posted by newport1 on 20-Feb-2014 02:33

My initial problem was that since we started using the new openedge version 11.2 it was no longer possible to programmatically work with Crystal Reports. At least not with our old code. And there were some examples online but only for vb.net and nothing for OpenEdge. So that is why I requested a Progress developer to take a look at it and he made some changes to my code to make it work.

Since there was so little working code out there I posted the relevant code here so anyone else struggling to get things working could use it and that would save them a lot of time and searching.

But thanks for the information regarding the 64 bit driver. I will surely take a look at it.

Dennis

This thread is closed