how to add data to a datagridview from an external library class

  • Thread starter Thread starter Royer12
  • Start date Start date
R

Royer12

Guest
Hello, I mean, I have a form 1 where I created a datagridview1 and with the motive of doing less lines, I want to create a library class.

My Form1

import MyLibrary
Public Class Form1
Dim cnn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source= data\mori.accdb;Persist Security Info=False")
Public Sub New()
'
InitializeComponent()
End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
MyLibrary(cnn) 'add cnn connection database
End Sub
End Class


In MyLibrary.vb -- or -- MyLibrary.dll

Imports System.Data.OleDb
Imports System.Windows.Forms

Public Class import_A
Private DataGridView1 As Object ' error not working

Public Sub New(ByVal conectar As String)
Dim da As New OleDbDataAdapter("SELECT Alumn.Id_alumn, Alumn.Name, Alumn.App, Alumn.Doc, Alumn.Proced, Esc.escs FROM Esc, Alumn WHERE Alumn.Id_esc = Esc.Id_esc", conectar)
Dim ds As New DataSet
da.Fill(ds)
DataGridView1.DataSource = ds.Tables(0) ' error

End Sub
End Class

Can you help me?

Continue reading...
 
Back
Top