This question have been inactivated and are not visible on this site.

ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

I am getting the following error when i am trying to open a oracle connection

ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

This is my Web.config where i have declared my connection string.

This is my entire code:
Imports System
Imports System.IO
Imports System.Data
'Imports System.Data.OracleClient
Imports System.Data.Odbc
Imports System.Data.SqlClient
Imports Microsoft.VisualBasic

Public Class CommonFunctions

'<ObsoleteAttribute("OracleConnection has been deprecated. http://go.microsoft.com/fwlink/?LinkID=144260", False)> Public NotInheritable Class OracleConnection Inherits CommonFunctions Implements ICloneable

'-----------------------------------------------------------------------------
' To Get the SQL Connection            Author: Nagarajan N    Date: 26/12/2011 
'-----------------------------------------------------------------------------
Public Shared Function getSConnection() As SqlConnection
    Dim sqlConnStr As String
    sqlConnStr = ConfigurationManager.ConnectionStrings("sqlServerConStr").ConnectionString
    Dim sqlConn As SqlConnection = New SqlConnection(sqlConnStr)
    Return sqlConn
End Function

'-----------------------------------------------------------------------------
' To Get the Oracle Connection         Author: Nagarajan N    Date: 26/12/2011 
'-----------------------------------------------------------------------------
Public Shared Function getOConnection() As OdbcConnection
    Dim oraConnStr As String
    oraConnStr = ConfigurationManager.ConnectionStrings("MsdsOnline").ConnectionString
    Dim oraConn As OdbcConnection = New OdbcConnection(oraConnStr)
    Return oraConn
End Function

'-----------------------------------------------------------------------------
' To fill the dropdown list            Author: Nagarajan N    Date: 26/12/2011     
'-----------------------------------------------------------------------------
Public Shared Sub fillDropdrownlist(ByVal sqlQuery As String, ByVal objDropdown As DropDownList, ByVal dtfName As String, ByVal dvfName As String)
    Dim oraDA As OdbcDataAdapter
    Dim oraDS As DataSet

    '----------------------------------
    Dim objConn As New System.Data.Odbc.OdbcConnection
    Dim objCmd As New System.Data.Odbc.OdbcCommand
    Dim dtAdapter As New System.Data.Odbc.OdbcDataAdapter
    Dim ds As New DataSet
    objConn.ConnectionString = ConfigurationManager.ConnectionStrings("MsdsOnline").ConnectionString
    With objCmd
        .Connection = objConn
        .CommandText = sqlQuery
        .CommandType = CommandType.Text
    End With
    dtAdapter.SelectCommand = objCmd

    dtAdapter.Fill(ds)
    dtAdapter = Nothing
    objConn.Close()
    objConn = Nothing

    '----------------------------------

    oraDA = New OdbcDataAdapter(sqlQuery, getOConnection())
    oraDS = New DataSet
    oraDA.Fill(oraDS, "AllTables")
    objDropdown.DataSource = oraDS
    objDropdown.DataSource = oraDS.Tables(0)
    objDropdown.DataTextField = oraDS.Tables(0).Columns(dtfName).ColumnName.ToString()
    objDropdown.DataValueField = oraDS.Tables(0).Columns(dvfName).ColumnName.ToString()
    objDropdown.DataBind()
    objDropdown.Items.Insert(0, "Select")
End Sub

I am getting an exception on the line dtAdapter.Fill(ds).

Thanks in advance

0 answers