Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...4D database4D database
Previous
 
Next
New Post
1/6/2009 2:09 AM
 

I might be a little late on this subject, but I'm using VS2008 to connect to a 4D database using ODBC.  Basically you have to install the ODBC driver from 4D.  There are different versions so you have to make sure you have the right one for the server to which you are connecting.

Next, you have to configure a DSN.  I have been reading that you don't need to do this with v11, but the one I'm using requires a DSN, so I have created a System DSN. 

Then you write code like this - bear in mind that this is bare bones code, so you'll need to beef it up with try/catch, etc...

using System.Data.Odbc;

public class blah

{
    private OdbcConnection _conn;
   

    private void MakeConnection()
    {

        _conn = new OdbcConnection("DSN=4D Connection;UID=USER;PWD=PASSWORD;");

        string sqlQuery = "SELECT * FROM BLAH WHERE THIS = 'THAT'";

        OdbcCommand odbcCmd = new OdbcCommand(sqlQuery, _conn);

        IDataReader dr = (IDataReader)odbcCmd.ExecuteReader();

        //hopefully, if everything is configured correctly your data will be in dr

    }

}

Hope that helps.  I know it's probably too late, but I thought I'd put in my two cents.

 
New Post
1/8/2009 6:59 PM
 

Fernando Durán wrote
 

I wonder if anybody could supply an example on how to connect to a 4D database.

you can find connection string examples at www.ConnectionStrings.com

you will need to use an ODBC or OLEDB provider, create a connection object of that type passing it the connection string, and then open the connection.  You would then create a command object specific to the provider that you'll be using (ODBC or OLEDB) indicating a database query and a reference to the connection object in it's constructor.  you can then use that command object's ExecuteReader method to return a DataReader object which you could persist through to access the data your query returned.

Matt Christenson

 
Previous
 
Next
HomeHomeDevelopment and...Development and...DNN Platform (o...DNN Platform (o...4D database4D database


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out