| | |
Data not being displayed correctly on datagridview
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jun 2008
Posts: 117
Reputation:
Solved Threads: 0
when i click "button1" on my form..i get field name as ' Expr1002' and the data in it are -1..
i believe it is soemthing to do with the da.fill() .. can u please asssist me with thsi ?
i believe it is soemthing to do with the da.fill() .. can u please asssist me with thsi ?
•
•
•
•
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim con As OleDbConnection = New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=C:\Documents and Settings\bashkark\Desktop\Copy of USERS.mdb")
Dim cmd As New OleDbCommand
con.Open()
cmd = New OleDbCommand("select MFG, MAKE, GRAPHICSCARD AND GRAPHICSVERSION from table1", con)
Dim da As OleDbDataAdapter = New OleDbDataAdapter(cmd)
Try
Dim ds As DataSet = New DataSet()
ds.Tables.Add("table1")
da.Fill(ds, "table1")
DataGridView1.DataSource = ds.Tables("table1").DefaultView
Finally
con.Close()
cmd = Nothing
da.Dispose()
con.Dispose()
End Try
End Sub
•
•
Join Date: Jun 2006
Posts: 1
Reputation:
Solved Threads: 0
Corrected Code Please Check
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim con As OleDbConnection = New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=C:\Documents and Settings\bashkark\Desktop\Copy of USERS.mdb")
Dim cmd As New OleDbCommand
Dim ds As DataSet = New DataSet()
con.Open()
cmd = New OleDbCommand("select MFG, MAKE, GRAPHICSCARD AND GRAPHICSVERSION from table1", con)
Dim da As OleDbDataAdapter = New OleDbDataAdapter(cmd)
da.fill(ds,"table1")
Try
'ds.Tables.Add("table1")
'da.Fill(ds, "table1")
'DataGridView1.DataSource = ds.Tables("table1").DefaultView
dataGridview1.datasource = ds
datagridview1.datamember = "table1"
Finally
con.Close()
cmd = Nothing
da.Dispose()
con.Dispose()
End Try
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim con As OleDbConnection = New OleDb.OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=C:\Documents and Settings\bashkark\Desktop\Copy of USERS.mdb")
Dim cmd As New OleDbCommand
Dim ds As DataSet = New DataSet()
con.Open()
cmd = New OleDbCommand("select MFG, MAKE, GRAPHICSCARD AND GRAPHICSVERSION from table1", con)
Dim da As OleDbDataAdapter = New OleDbDataAdapter(cmd)
da.fill(ds,"table1")
Try
'ds.Tables.Add("table1")
'da.Fill(ds, "table1")
'DataGridView1.DataSource = ds.Tables("table1").DefaultView
dataGridview1.datasource = ds
datagridview1.datamember = "table1"
Finally
con.Close()
cmd = Nothing
da.Dispose()
con.Dispose()
End Try
End Sub
![]() |
Other Threads in the VB.NET Forum
- Previous Thread: Backup of sql server using vb.net code
- Next Thread: Need help at sending XML File to Server
Views: 682 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for VB.NET
.net .net2008 2008 access add advanced application array basic beginner browser button buttons center click client code combo convert cpu cuesent data database datagrid datagridview datetimepicker designer dissertation dissertations dissertationtopic eclipse employees excel exists filter forms function html images lib listview map mobile module msaccess mysql net number objects open page pan panel pdf picturebox picturebox2 port position print printing printpreview problem read regex reuse richtextbox right-to-left save search serial settings socket sorting sqldatbase sqlserver storedprocedure textbox timer timespan transparency txttoxmlconverter usercontol vb vb.net vb2008 vba vbnet vista visual visualbasic visualbasic.net visualstudio.net visualstudio2008 web webbrowser winsock wpf wrapingcode xml year





