ReportByEmail
ODBC Connection setup
ReportByEmail – RBE ODBC Connection setup Content
Introduction ... 3
ReportByEmail Server and changing ODBC settings ... 3
Microsoft AD Windows setup... 3
Important notice regarding 32-bit / 64-bit versions of Windows ... 3
Setup ODBC datasources on server and clients ... 4
Oracle ODBC Connections ... 10
Excel sheets and Oracle ODBC Drivers ... 12
Microsoft Access ODBC Sources ... 17
MySQL ODBC-driver ... 22
Other third party ODBC drivers ... 22
All other ODBC resources ... 22
ODBC System resources on Server and clients... 23
ODBC setup shortcut ... 23
Windows Registry Warning ... 23
Windows Registry backup - general ... 23
Export ODBC registry settings – 32bit ... 24
Export ODBC registry settings – 64bit ... 27
ODBC settings import ... 27
Microsoft Active Directory Registry settings for ODBC ... 28
ReportByEmail – RBE ODBC Connection setup
Introduction
The manual describes setting up ODBC connections to Microsoft SQL Server and other servers. Setting up theses connections are needed on all client machines and the ReportByEmail server in order to allow Excel to with the same database resources from the different machine.
ReportByEmail Server and changing ODBC settings
Please notice, that the ReportByEmail server reads ODBC settings at start up. If you change the ODBC settings, ReportByEmail will not recognize this before the ReportByEmail server service has been stopped and started.
Microsoft AD Windows setup
During this setup it’s expected, that the Preparation Before install Server document has been followed regarding all AD settings. Otherwise your rights to the Microsoft SQL server databases will no be in place and you will not succeed in getting connections to your databases.
Important notice regarding 32-bit / 64-bit versions of Windows
It’s important to understand which kind of DSN you have. On an x64 system, you can create an ODBC connection (DSN) on the 32-bit side of the system or on the 64-bit side of the system.
32-bit applications will only see ODBC connections created in the 32-bit side, and 64- bits applications will only see ODBC connections from the 64-bit side. Each kind of application has is own registry settings in separate locations of the registry.
To setup DSN for 32-bit application you must use:
%WINDIR%\SysWOW64\odbcad32.exe and for 64-bit application you must use:
%WINDIR%\System32\odbcad32.exe
There is not 32-bit edition of Windows XP on the XP Pro x64 media.
http://support.microsoft.com/kb/942976/en-us
So if you have created an ODBC System DSN, as specified in the following sections and you can’t see it from Microsoft Excel, you’re probably running a 64-bit operating system and used the “wrong” odbcad32.exe file. In this case run:
ReportByEmail – RBE ODBC Connection setup
%WINDIR%\SysWOW64\odbcad32.exe And define the ODBC connection there.
Setup ODBC datasources on server and clients
ReportByEmail uses ODBC-connections to communicate with databases. This section describes how to setup ODBC sources.
Start / Settings / Control panel.
Administrative tools.
Data Sources (ODBC)
The following default window appears:
Change to the System DSN window. Depending on which server is used, some ODBC connections might have been created already:
ReportByEmail – RBE ODBC Connection setup
Create a ODBC connection for the Microsoft Navision database. Click on Add:
Select the SQL Server driver, which is usually located at the bottom of the list.
Therefore press the end-key:
ReportByEmail – RBE ODBC Connection setup After pressing Finish the following window shows up:
Enter a name for the connection, for instance Navision. Description is not used. In the server field select the Microsoft SQL server, which holds the database:
ReportByEmail – RBE ODBC Connection setup Click Next, not finish:
Accept the default settings and click Next:
ReportByEmail – RBE ODBC Connection setup
In this window, it’s important to change the default database to the name selected previously. Especially the ReportByEmail functionality with “SQL table lookup of recipients” won’t work, if the correct database is not selected.
Click Next.
ReportByEmail – RBE ODBC Connection setup Click Finish.
Click Test Data Source:
ReportByEmail – RBE ODBC Connection setup Congratulations!
Oracle ODBC Connections
This is highly complicated due to limitations in the ODBC drivers. Basically you need to install an Oracle client on the ReportByEmail server, if you want to access Oracle data.
Please perform an Oracle client installation first.
After installation of the Oracle client you can choose between two ODBC Drivers:
Microsoft ODBC for Oracle 2.576.3959.000 Oracle in Orahome92 9.02.00.00
If you’re not at the same version level for the Microsoft ODBC Driver, please download and install Microsoft MDAC 2.8 or newer.
Depending on the version of Oracle installed, the version will of course differ from the listed version 9.2 above.
Unfortunately there is a bug in the Oracle client, which means you need to do some manual adjustments to registry. The ODBC driver uses DLL’s supplied by Oracle, but wrong/old Dll’s are referenced in registry.
Open registry by choosing Start / Run / Regedit.
Browse to HKEY_LOCAL_MACHINE / SOFTWARE / Microsoft / MSDTC / MTxOCL.
ReportByEmail – RBE ODBC Connection setup The originally settings are often se to the following:
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSDTC\MTxOCI]
"OracleXaLib"="xa80.dll"
"OracleSqlLib"="SQLLib80.dll"
"OracleOciLib"="oci.dll"
Change these to:
"OracleXaLib"="oraclient9.dll"
"OracleSqlLib"="orasql9.dll"
"OracleOciLib"="oci.dll"
If running Oracle version 9. If running version 10, replace all 9’s with 10’s.
After the changes, the values should look like the following:
Check to see that the new DLL-files are located in the C:\oracle\ora92\bin directory.
The ODBC driver will not work unless the Dll-files listed above exists and their location on the server is included in the ReportByEmail server PATH variable.
To test the database connection, please consult and check that connectivity is okay by using Oracle client. Use:
Tnsping axdb
To test connection to an Microsoft Axapta database on Oracle.
Inspect the tnsnames.ora file located in: C:\oracle\ora92\network\ADMIN.
Also check that C:\oracle\ora92\bin is included in the ReportByEmail server PATH variable.
ReportByEmail – RBE ODBC Connection setup
Excel sheets and Oracle ODBC Drivers
Since Oracle does not have Microsoft AD integration, trusted access for the ReportByEmail server to the Oracle databases is not supported. The username and password for access to the Oracle database needs to be entered into all Excel sheets.
Default Excel does not generate the correct ODBC connection string, so modifications are needed.
When creating a new Excel sheet, choose select data from external source using MS Query:
In the example above, axdb is a Oracle ODBC Driver and axdbms is a Microsoft ODBC driver for Oracle.
The genuine Oracle driver does not support the date- and time-fields in MS Query, which makes it very difficult to design queries using the Oracle driver from oracle.
The Microsoft ODBC driver does support the date and time-formats, so designing reports in MS Query is as easy as when designing Excel sheets against Microsoft SQL Servers.
Choose the axdbms in this example.
This window is very important. The User name and password is the Oracle username and password. Enter whose values. In the server field, DO NOT put the name of the Oracle server! You need to put in the TNS-name of the database, in this case axdbms.
This is not documented, so please check this, if something does not work for you!
ReportByEmail – RBE ODBC Connection setup Click Ok.
The data tables in the axdbms database shows up and choosing tables is done the same way as with Microsoft SQL server.
After choosing a table like ADDRESS, the data is returned to the Excel sheet.
In order to get this to work during execution under ReportByEmail, the password needs to be added.
Choose Data, Connections, Properties on the query:
ReportByEmail – RBE ODBC Connection setup Change to definition:
ReportByEmail – RBE ODBC Connection setup
Notice that the Connectionstring in the top block does not contain any password. The syntax for Oracle passwords is: PWD=<password>. After inserting this into the text and enabling “Save password”, the connection looks like this:
ReportByEmail – RBE ODBC Connection setup Now the report can run under ReportByEmail.
ReportByEmail – RBE ODBC Connection setup
Microsoft Access ODBC Sources
ODBC data sources are setup similar to Microsoft SQL servers, but with a few different challenges:
Always use UNC-paths when addressing a Microsoft Access Database, e.g. the full path like in:
\\cphfile\d$\test\data\database\testdb.mdb
Always setup the Defaultdir to the same path as the UNC-path above, e.g.:
\\cphfile\d$\test\data\database
If you setup an ODBC connection to a mapped drive, it will work when running the Excel queries manually, even on the ReportByEmail server, but when the ReportByEmail service is running, the mapped drive will not be mapped (Microsoft design) and the data will not be accessible from Excel.
The UnitekDB and UnitekLog databases are both Microsoft Access databases. Choose Configure….
ReportByEmail – RBE ODBC Connection setup
If logging is enabled (Multi-user environment), you might have to point to a Systemdatabase in the lower part of the window. Choose “Vælg” / “Select”:
The URL has been pasted into the databasename to the upper left. Notice the tree- structure in the window in the middle. Always use an UNC path and not a mapped drive. Don’t click on “Netværk” / “Network” and map a drive.
Back in the main view select “Avanceret” / “Advanced”:
ReportByEmail – RBE ODBC Connection setup
If the Microsoft Access database is protected with username and password, insert this In the window above top to lines.
Check that the DefaultDir is similar to the path where the database is located as specified in the beginning of this section.
You can also set the readonly attribute:
ReportByEmail – RBE ODBC Connection setup
This ensures that you can never write anything back to Access database, e.g.
ReportByEmail is only used to extract data from the Access database.
After you have defined a report in Excel using MS Query, check the settings:
ReportByEmail – RBE ODBC Connection setup
Notice that the DBQ and DefaulrDir parameters in the “Forbindelsesstreng” /
“Connection string” does not contain any mapped drives, but UNC paths. If you define a report using a mapped drive, changing the ODBC source WILL NOT change this setting above and you will still try to connect to the database using a mapped drive.
You need to change the Connection string setting above to use UNC path as showed above.
ReportByEmail – RBE ODBC Connection setup
MySQL ODBC-driver
Visit:
http://dev.mysql.com/downloads/connector/odbc
to download the newest ODBC driver for the MySQL database.
Choose a MSI-version of the driver and download it to a temporary location. Run the MSI-file.
Other third party ODBC drivers
Please remember, that only a limited number of drivers are default installed on a typical Windows 2003 server, Windows XP or Windows Vista client.
In order to get ODBC connections to work with MySql and other third party ODBC products, you need both to install the ODBC drivers and define the ODBC sources.
E.g.
First install the driver as specified by the producer.
Then define the ODBC settings as described above or follow the advices in the following section regarding easy copying of ODBC settings from machine to machine.
All other ODBC resources
Do the same as described above for all other databases.
You could very well end up with many ODBC resources in the System folder – maybe 10 or more.
ReportByEmail – RBE ODBC Connection setup
ODBC System resources on Server and clients
All these ODBC settings need to be setup on the ReportByEmail server AND on all clients, which will be developing Excel sheets for ReportByEmail. The name of the ODBC Source (In this case Navision) needs to be the same both on the clients and on the server if using NT Authentication, which is by far the easiest way of working with ReportByEmail.
ODBC setup shortcut
You can copy ODBC settings from one machine to another. This involves editing registry of the machines involved. There is always a risk, that you might harm the machine and that you can’t get it up running again, if you use Microsoft Registry incorrect.
Notice that you can not copy the registry keys between 32-bit operating systems and 64-bit operating systems.
If you’re running Windows XP 32-bit and Windows server 2003 32-bit, it works fine. If you’re running Vista 64-bit or Windows 2008 server 64-bit it also works. But if you have a mix of platforms, copying is not possible. In this case you need to maintain to sets of registry files (see explanation later).
Windows Registry Warning
If you read almost any article in the Microsoft Knowledge Base that suggests editing the Windows registry, you will see this:
WARNING: Using Registry Editor incorrectly can cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that problems resulting from the incorrect use of Registry Editor can be solved. Use Registry Editor at your own risk.
Note that you should back up the registry before you edit it.
Windows Registry backup - general
Problems caused by improperly editing the Windows registry could render your computer operating system unusable. Microsoft provides a wealth of critical informa- tion that you need to know about the registry in the Microsoft Knowledge Base at http://support.microsoft.com/support.
Additional information about the registry is also available in the Help topics in the Microsoft Registry Editor.
ReportByEmail – RBE ODBC Connection setup To back up the registry:
On the Start menu (Windows), click Run.
In the Open box, enter regedit, and then click OK.
In the Registry Editor, on the Registry menu, click Export Registry File.
From the Save As Type drop-down list, select Registration Files (*.reg).
Under Export Range, click All.
In the File Name box, enter Backup Registry.
In the Save In box, select Desktop.
In the upper right corner of the Export Registry File dialog box, click Create New Folder, and then enter My Backup Files.
Click Save.
Note: You have just saved the Backup Registry file to the My Backup Files folder on the desktop. In each of the following back-up procedures, you will be instructed to save your files to the same folder.
On the Registry menu, click Exit.
Verify that the Registry Backup.reg file is located in the My Backup Files folder. To do this, double-click the My Backup Files folder on the desktop and note the contents.
If the file is there, close the My Backup Files folder. If the file is not there, repeat steps 1 through 9, but in step 8, do not create a new folder; instead, select the My Backup Files folder.
Export ODBC registry settings – 32bit
Go to Start / Run…. And enter the text:
Regedit Browse to:
My Computer\HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI It’s very important not to delete or move any entries!
See the list:
Here you can see all the ODBC drivers located in the System folder of the ODBC setup.
ReportByEmail – RBE ODBC Connection setup
Place the cursor above the ODBC.INI location and Choose file / Export… in the menu:
Browse to a location on a network-share, where you can access the file from other clients that needs to ODBC setup. The path at the bottom of the window is very important and must be the same.
Fill in the file name with RBEODBC.REG:
ReportByEmail – RBE ODBC Connection setup Press save.
If you browse to the new folder, you’ll see one file:
ReportByEmail – RBE ODBC Connection setup
Export ODBC registry settings – 64bit
Go to Start / Run…. And enter the text:
Regedit Browse to:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBC.INI
Note the difference from 32-bit editions, where you go to a different SOFTWARE folder.
ODBC settings import
Access this from another computer, where you would like to have the same ODBC connection and double-click on the file:
Press Yes and the ODBC sources are available on the new machine..
Remember to import the correct version (32-bit or 64-bit). If the imported registry does not show up in the ODBC under Administrative tools, you are probably mixing the platforms.
ReportByEmail – RBE ODBC Connection setup
Microsoft Active Directory Registry settings for ODBC
If you have a server and a number of clients, it’s easy to manage ODBC settings in a Microsoft Active Directory Group Policy. If a ReportByEmail client gets a new PC, it’s very easy to apply all the ODBC settings and changing from one SQL server to another is also very easy to apply to all clients and the server.
Currently you will need an Active Directory at least at level “Windows AD 2008”.
Unfortunately this are bugs in the utility used to define the group policy, which means that the most obvious way of defining the settings using the ODBC Setting does not work.
Do the following on a machine, that already has the ODBC drivers defined locally:
In Microsoft AD Users and Computers, define a new “Organization Unit” and move all clients and the ReportByEmail server to this container.
Open Microsoft AD Group Policy. Create a new policy called ODBC. Go to the area with registry settings, right-click and select Import… Point to the same registry areas as specified above and import all ODBC settings, e.g.
My Computer\HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI Save this group policy.
Create a new one called ODBCWOW. This is used to handle machines with different bit versions of Excel and the operating system. Import the same ODBC drivers from the SYSWOW64 location also as specified earlier in this document:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBC.INI Apply both policies on the newly created Organization Unit.
On the ReportByEmail machines involved run in DOS:
GPUPDATE /FORCE
This forces the machines to update with the newest settings. Some machines might require a reboot.
After a reboot check the ODBC settings and see that they all work.
If a new client PC needs the ODBC settings, move the machine to the Organizational Unit or apply the two group policies to the Organizational Unit, where the machine is located.