Conexión con B.D. en access
Publicado por Miguel (281 intervenciones) el 01/07/2015 14:06:36
Tengo un modulo para conectar con la BD en access que me funciona correctamente. Es este :
Y lo que hago es hacer el modulo como una dll. Pues como dll me error en "Application"
Podría alguien decirme en que consiste el fallo.
Gracias
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
Option Explicit On
Imports System.Data.OleDb
Module modConexion
Public da As New OleDbDataAdapter
Public ds As New DataSet
Public dt As New DataTable
Public cn As New OleDb.OleDbConnection
Sub Open(ByVal BD As String)
Try
cn = New OleDbConnection
cn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source =" &
Application.StartupPath.Substring(0, Application.StartupPath.Length) & "\" & BD
cn.Open()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
End Module
Y lo que hago es hacer el modulo como una dll. Pues como dll me error en "Application"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
Option Explicit On
Option Strict On
Imports System.Data.OleDb
Namespace Conectar
Public Class clsConexion
Private Paht As String
Private cn As OleDbConnection
Public Sub Open(ByVal BD As String)
Try
Paht = Application.StartupPath.Substring(0, Application.StartupPath.Length) & "\" & BD
Dim Conectar As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source =" & Paht
cn = New OleDbConnection(Conectar)
cn.Open()
Catch ex As Exception
MsgBox("Can not open connection ! ")
End Try
End Sub
Public Sub Close(ByVal BD As String)
cn.Close()
End Sub
End Class
End Namespace
Podría alguien decirme en que consiste el fallo.
Gracias
Valora esta pregunta


0