ODBC Multiple companies.

delaghettodelaghetto Member Posts: 89
Hi,

We have a Navision 4.0 SP3 Database with over 40 companies.

We need to extract data from this database using the ODBC Connector. I'm using a c# script, and have created a odbc data source and using code:

OdbcConnection DbConnection = new OdbcConnection("DSN=nav_database");
try
{
DbConnection.Open();
..... etc etc...

Can I add something to the connection string so that I can choose de company from code? It's a total ](*,) having to create over 40 datasources in the ODBC administrator.

Thanks!

Comments

  • ara3nara3n Member Posts: 9,256
    one option is to migrate to sql.
    The other option is to use cfront
    3rd option is to integrate using NAS
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • MarkHamblinMarkHamblin Member Posts: 118
    I assume this is the classic DB and not SQL.

    The ODBC DSN info is stored in the registry and is easily accessible. Knowing that, here are a few creative options:
    • Before connecting to the DSN, update the registry with the company you want to connect to (I've used this in a different but similar situation, and it works fine)
    • Create 40 DSNs, just do it via textpad/notepad by exporting your nav_database DSN and copying and pasting the details for each company
    • Create a C# app to create the DSNs
  • delaghettodelaghetto Member Posts: 89
    Thanks for the answers guys!

    Mark's idea about the registry update from c# worked for me.

    I create the ODBC connection using any company. Then from C# I query the "Company" Table, and for each line, I update the registry key HKLM/software/ODBC/ODBC.ini/NavisionDataSource/CompanyName and read all the data I need from each.

    This site helped:

    http://www.mojobudgie.com/a-very-simple ... try-value/

    :thumbsup:
Sign In or Register to comment.