Cita:
Corregido, no se puede cambiar la instancia en un metodo cuando fue creada en otro, hay que enviarle por parametro el objeto correspondienteQuiza se les haga familiar el titulo, y quiza me manden al foro donde ya se resolvio, pero les comentare, ya lo lei y aun no logro solucionarlo, me lo tope en una clase que estoy haciendo, estoy ocupando VB 2010 y aun no lo corrijo, alguien puede apoyarme? es al momento de tratar de crear la conexion con la base de datos que contiene los archivos .dbf (recordemos que la base de datos es solo una carpeta)
Este es el codigo:
Este es el codigo:
Código Clase VB 2010:
Ver original
Imports System.Data Public Class Connect_DataBase Public driver As String Public database As System.Data.Odbc.OdbcConnection 'Public database As OleDb.OleDbConnection Public status_message As String Public select_string = "Select * from " Public Sub New(ByVal sPath As String) driver = "Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=" & sPath & ";" 'driver = "Provider=Microsoft.Jet.OLED B.4.0;Data Source=" & sPath & "; Extended Properties=dBASE IV;" 'Dim connAs New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLED B.4.0;Data Source=C:\DB; Extended Properties=dBASE IV;") MessageBox.Show(driver) Using database As New System.Data.Odbc.OdbcConnection(driver) 'Using database As New OleDb.OleDbConnection(driver) Try Open() 'Status = "Connected" Catch ex As Exception MessageBox.Show("DataBase Not Found" & vbCrLf & "Select Another Path" & vbCrLf & ex.Message) 'Status = "Error" End Try End Using End Sub Public Property Status() As String Get Return status_message End Get Set(ByVal value As String) MessageBox.Show("Llegando") status_message = value End Set End Property Public Sub Open() database.Open() End Sub Public Sub Close() database.Close() End Sub Public Sub OpenTable(ByVal tableName As String) Try Dim data As New System.Data.Odbc.OdbcDataAdapter(select_string & tableName, database) 'Dim data As New OleDb.OleDbDataAdapter(select_string & tableName, database) Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub End Class
Código Clase Corregida VB 2010:
Ver original
Imports System.Data Public Class Connect_DataBase Public driver As String Public Shared database As System.Data.Odbc.OdbcConnection Public status_message As String Public select_string = "Select * from " Public Sub New(ByVal sPath As String) driver = "Driver={Microsoft dBASE Driver (*.dbf)};DriverID=277;Dbq=" & sPath & ";" Using database As New System.Data.Odbc.OdbcConnection(driver) Try Open(database) Status = "Connected" Catch ex As Exception MessageBox.Show("DataBase Not Found" & vbCrLf & "Select Another Path") Status = "Error" End Try End Using End Sub Public Property Status() As String Get Return status_message End Get Set(ByVal value As String) status_message = value End Set End Property Public Sub Open(ByVal connection As System.Data.Odbc.OdbcConnection) connection.Open() End Sub Public Sub Close(ByVal connection As System.Data.Odbc.OdbcConnection) connection.Close() End Sub Public Sub OpenTable(ByVal tableName As String) Try Dim data As New System.Data.Odbc.OdbcDataAdapter(select_string & tableName, database) Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub End Class
Este mensaje puede cerrarse para evitar futuras respuestas
Gracias por al menos leer mi duda