Hello there,
I've always used datagridview with local ms access db, without any troubles.
I've been asked to create a solution, so that users can select, add, delete data from one table. The problem is that the path to this db is not the same for everyone.
I'm using this:
Imports System.Data.OleDb
Module Module1
Dim con As New OleDbConnection
Public Sub Get_Connection()
con.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0; Data Source = " & My.Settings.BDpath
con.Open()
End Sub
Public Sub DisplayDataGrid()
Dim lista As New Form3
Dim ds As New DataSet
Dim dt As New DataTable
Dim da As New OleDbDataAdapter
Dim cmd As String
cmd = "Select * From Registo;"
ds.Tables.Add(dt)
da = New OleDbDataAdapter(cmd, con)
da.Fill(dt)
MsgBox(cmd)
lista.DataGridView1.DataSource = dt.DefaultView
con.Close()
End Sub
my.settings.bdpath text is = "C:\Users\fcosta\Desktop"
i've set it to run when form is loaded, but i can't get it to work.
Public Class Form3
Private Sub Form3_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Get_Connection()
DisplayDataGrid()
End Sub
End Class
What I have tried:
I've pretty much read the first two pages of google relationed with datagridviews and still, can't get it to work.