I Connected My DB(Created using Acces 2017 ) To Visual Basic Using Oledb4.0 The problem i'm facing is that the datagridview show duplicated rows For Example on my DB I have 2 rows it Will show four rows What is the problem ?
cnx = New OleDbConnection
dbProvider = "Provider=Microsoft.Jet.OLEDB.4.0;"
dbSource = "Data Source =C:\Users\ABK\Desktop\PFA\FLYY.mdb"
cnx.ConnectionString = dbProvider & dbSource
cnx.Open()
sql = "SELECT DISTINCT Login.* from Login"
cmd = New OleDbCommand(sql)
dta = New OleDbDataAdapter(cmd)
cmd.Connection() = cnx
dta.Fill(dts, "Login")
dtt = dts.Tables("Login")
Dim dr As OleDbDataReader
dr = cmd.ExecuteReader
dtt.Load(dr)
DataGridView1.DataSource = dtt
dta.Fill(ds, "Login")
dsview = ds.Tables("Login").DefaultView
bs.DataSource = dsview
You don't need to call DataTable.Load
if you already .Fill
it.
So you can remove:
Dim dr As OleDbDataReader
dr = cmd.ExecuteReader
dtt.Load(dr)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.