Question : Help Need to resole this error SqlClient.SqlConnection' cannot be converted to 'System.Data.OleDb.OleDbConnection'.

I am returning a sql connection string I need to  fix ths  how ?
 
Director.GetNewOpenDbConnection() the value being returned

------------------------------------
Compiler Error Message: BC30311: Value of type 'System.Data.SqlClient.SqlConnection' cannot be converted to 'System.Data.OleDb.OleDbConnection'.

Source Error:

Line 133:            Using connection As OleDbConnection = Director.GetNewOpenDbConnection()
Line 134:                'Me.ILoad_MultipleImages1.Values = ILoadASCX.MultipleImages.ILoad_MultipleImages_Helper.LoadValuesFromDB(connection, this.ILoad_MultipleImages1.ILoad.Configuration.InternalCode, imageId)
Line 135:                Me.ILoad_MultipleImages1.LoadValuesFromDB(connection, imageId)
 


Using connection As OleDbConnection = Director.GetNewOpenDbConnection()
            'ILoadASCX.MultipleImages.ILoad_MultipleImages_Helper.SaveValuesToDB(Me.ILoad_MultipleImages1.Values, connection, Me.ILoad_MultipleImages1.ILoad.Configuration.InternalCode, imageId)
            Me.ILoad_MultipleImages1.SaveValuesToDB(connection, imageId)
        End Using
1:
2:
3:
4:
5:
6:
7:
this is returning the proper connection string
------------------------------------------------
Public Shared Function GetNewOpenDbConnection() As SqlConnection
        Dim connection As SqlConnection = New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("Db1ConnectionString").ConnectionString)
        connection.Open()
        Return connection
    End Function

Answer : Help Need to resole this error SqlClient.SqlConnection' cannot be converted to 'System.Data.OleDb.OleDbConnection'.

Using connection As OleDbConnection = Director.GetNewOpenDbConnection()

should be

Using connection As SqlConnection = Director.GetNewOpenDbConnection()

because this is the type of connection your function is returning
Random Solutions  
 
programming4us programming4us