7 Replies - 1375 Views - Last Post: 02 August 2012 - 09:15 AM Rate Topic: -----

#1 Cmore86  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 63
  • Joined: 01-August 12

Informix DSN connection via Windows Form

Posted 01 August 2012 - 02:29 PM

Good Afternoon,

I am trying to establish a connection to a DSN server to pull data from our Cisco Phone System using the Informix Drivers provided in 32bit. I have tried a variety of methods and it seems that the error is happening once I try to connect to the DSN. I have tried with and without the password and username in order to connect to it and have been banging my head against the wall trying to figure this out.


The code is simple and is as follows

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.Odbc;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace RSQ_App_V1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            try
            {
                OdbcConnection connection = new OdbcConnection();
                connection.ConnectionString = "DSN='UCCX";

   
                string queryString = "SELECT totalcalls FROM rtcsqssummary WHERE csqname='RSQ-Spanish' OR csqname='RSQ-English'";
               
                OdbcCommand command = new OdbcCommand(queryString, connection);
               
                MessageBox.Show("IT Breaks after this....");

                connection.Open();
                
                MessageBox.Show("You solved the connection issue!");

                OdbcDataReader reader = command.ExecuteReader();
                textBox1.Text = queryString;
                DataTable dt = new DataTable("UCCXData");
                dt.Load(reader);
                reader.Close();
                connection.Close();
                //fill the dataview
                dvData.DataSource = dt;

                

                
                ////int TotalContactsWaiting = 0;
                ////ODBC Connection
                //OdbcConnection DbConnection = new OdbcConnection("DSN=UCCX");
                //string queryString = "SELECT totalcalls from FROM rtcsqssummary WHERE csqname='RSQ-Spanish' OR csqname='RSQ-English'";
                //OdbcCommand DbCommand = DbConnection.CreateCommand();            

                ////Open connection
                //DbConnection.Open();
                
                ////DbCommand.CommandText = "SELECT SUM(totalcalls) AS stotalcalls, SUM(callswaiting) AS scallswaiting, SUM(oldestcontact) AS soldestcontact, SUM(callshandled) AS scallshandled, SUM(callsabandoned) AS scallsabandoned, SUM(longesttalkduration) AS slongesttalkduration FROM rtcsqssummary WHERE csqname='RSQ-Spanish' OR csqname='RSQ-English'";
                               
                //OdbcDataReader DbReader = DbCommand.ExecuteReader();
                
                //TotalContactsWaiting = Convert.ToChar("scallswaiting");
                //test1.Text = TotalContactsWaiting;

                //DbReader.Close();
                //DbCommand.Dispose();
                //DbConnection.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show("there was an error - " + ex);
                
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'dataSet1.rtcsqssummary' table. You can move, or remove it, as needed.
            this.rtcsqssummaryTableAdapter.Fill(this.dataSet1.rtcsqssummary);

        }

        
      
    }
}


 


The error I am getting is as follows:

System.Data.Odbc.OdbcException (0x80131937): ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)
at System.Data.Odbc.OdbcConnectionHandle..ctor(OdbcConnection connection, OdbcConnectionString constr, OdbcEnvironmentHandle environmentHandle)
at System.Data.Odbc.OdbcConnectionOpen..ctor(OdbcConnection outerConnection, OdbcConnectionString connectionOptions)
at System.Data.Odbc.OdbcConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionInternal.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory)
at System.Data.Odbc.OdbcConnection.Open()
at RSQ_App_V1.Form1..ctor()


I have tried google and a variety of other methods to try to figure this out and have made no progress on this.

It seems that my issue is connecting to the DSN, once that is established I should be able to move forward from there and pull the data that is needed.

Any help would be greatly appreciated.

Thank you,

Cesar

Is This A Good Question/Topic? 0
  • +

Replies To: Informix DSN connection via Windows Form

#2 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 1915
  • View blog
  • Posts: 5,722
  • Joined: 05-May 12

Re: Informix DSN connection via Windows Form

Posted 01 August 2012 - 02:46 PM

Are you running in 64-bit Windows? If so, change your build from targeting AnyCPU, to target x86 because a 64-bit process can't load 32-bit DLLs. ODBC drivers are just DLLs.
Was This Post Helpful? 1
  • +
  • -

#3 Cmore86  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 63
  • Joined: 01-August 12

Re: Informix DSN connection via Windows Form

Posted 01 August 2012 - 02:59 PM

View PostSkydiver, on 01 August 2012 - 02:46 PM, said:

Are you running in 64-bit Windows? If so, change your build from targeting AnyCPU, to target x86 because a 64-bit process can't load 32-bit DLLs. ODBC drivers are just DLLs.

I've attempted that and came across the same error.
Was This Post Helpful? 0
  • +
  • -

#4 Skydiver  Icon User is online

  • Code herder
  • member icon

Reputation: 1915
  • View blog
  • Posts: 5,722
  • Joined: 05-May 12

Re: Informix DSN connection via Windows Form

Posted 01 August 2012 - 03:10 PM

I assume you also create the DSN named UCCX?

Have you also tried taking the single quotes out of your connection string?
Was This Post Helpful? 1
  • +
  • -

#5 Cmore86  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 63
  • Joined: 01-August 12

Re: Informix DSN connection via Windows Form

Posted 01 August 2012 - 03:57 PM

View PostSkydiver, on 01 August 2012 - 03:10 PM, said:

I assume you also create the DSN named UCCX?

Have you also tried taking the single quotes out of your connection string?



I have not tried it that way will attempt that and as if that works.
Was This Post Helpful? 0
  • +
  • -

#6 Cmore86  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 63
  • Joined: 01-August 12

Re: Informix DSN connection via Windows Form

Posted 02 August 2012 - 06:11 AM

View PostCmore86, on 01 August 2012 - 03:57 PM, said:

View PostSkydiver, on 01 August 2012 - 03:10 PM, said:

I assume you also create the DSN named UCCX?

Have you also tried taking the single quotes out of your connection string?



I have not tried it that way will attempt that and as if that works.


The DSN is created and removed the single quote to see if it was the cause and I still get the same error.

I am stumped at what the solution is.

Will try on a different PC and see if it might be an installation issue.
Was This Post Helpful? 0
  • +
  • -

#7 Cmore86  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 63
  • Joined: 01-August 12

Re: Informix DSN connection via Windows Form

Posted 02 August 2012 - 06:55 AM

When I attempt this on another PC, it works just fine. It seems to be a corrupted VS install or the DSN is installed improperly.
Was This Post Helpful? 0
  • +
  • -

#8 Cmore86  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 63
  • Joined: 01-August 12

Re: Informix DSN connection via Windows Form

Posted 02 August 2012 - 09:15 AM

Was able to fix it now I have to just figure out how to pull the data from the Dataview.

Thanks for your help.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1