Unable to show data in datagridview
-
I am unable to show data on datagridview using the following code. Can anybody help me please. Nothing showing in datagridview but no error message displayed. Suman Dim str As String Dim mycon As New OleDb.OleDbConnection Dim da As OleDbDataAdapter Dim ds As New DataSet Dim dt As New DataTable Dim dv As New DataView str = "Provider=Microsoft.jet.oledb.provider.4.0; Data Source=Nwind.mdb;" mycon.ConnectionString = str mycon.Open() str = "select * from customers" da = New OleDbDataAdapter(str, mycon) da.Fill(ds) DGV.DataSource = ds.DefaultViewManager
-
I am unable to show data on datagridview using the following code. Can anybody help me please. Nothing showing in datagridview but no error message displayed. Suman Dim str As String Dim mycon As New OleDb.OleDbConnection Dim da As OleDbDataAdapter Dim ds As New DataSet Dim dt As New DataTable Dim dv As New DataView str = "Provider=Microsoft.jet.oledb.provider.4.0; Data Source=Nwind.mdb;" mycon.ConnectionString = str mycon.Open() str = "select * from customers" da = New OleDbDataAdapter(str, mycon) da.Fill(ds) DGV.DataSource = ds.DefaultViewManager
hi, if dataset contains data(verify it in debug mode) , then try this code DGV.DataSource = ds.Tables(0) in place of
DGV.DataSource = ds.DefaultViewManager
hop this helps
Rupesh Kumar Swami Software Engineer, Integrated Solution, Bikaner (India) My Company
-
hi, if dataset contains data(verify it in debug mode) , then try this code DGV.DataSource = ds.Tables(0) in place of
DGV.DataSource = ds.DefaultViewManager
hop this helps
Rupesh Kumar Swami Software Engineer, Integrated Solution, Bikaner (India) My Company
Sorry, it is not working. Should I change any properties to show data? Suman
-
Sorry, it is not working. Should I change any properties to show data? Suman
hi suman, there r no mistake in code. are you sure, query return some records ? Verify it in debug mode
Rupesh Kumar Swami Software Engineer, Integrated Solution, Bikaner (India) My Company
-
hi suman, there r no mistake in code. are you sure, query return some records ? Verify it in debug mode
Rupesh Kumar Swami Software Engineer, Integrated Solution, Bikaner (India) My Company
Good Morning fellows, I always use the following procedure to receive Data from the Jet-Engine or even from the MS-SQL-Server Imports System.Data.OleDb ... Dim oOleDbConnection As OleDbConnection Dim DBAdapt As OleDbDataAdapter Dim DT As New DataTable DIM SQLT as String Dim DBPath as String '***Don't forget to specify the correct databasepath DBPath="C:\mypath\nwind.mdb" Dim sConnString As String = _ "Provider=Microsoft.Jet.OLEDB.4.0;" & _ "Data Source=" & DBPath & ";" & _ "User ID=Admin;" & _ "Password=" oOleDbConnection = New OleDb.OleDbConnection(sConnString) oOleDbConnection.Open() '***check if the Connection had opened correct. If not '***you receive a first tip where the probleme might be If oOleDbConnection.State = ConnectionState.Open Then '***Set the SQL-Statement SQLT="Select * from Customer;" '***Create a new Adapter-Object Dim DBAdapt As New OleDbDataAdapter(SQLT, oOleDbConnection) '***Because of the fact that we only select Data from one Table '***it is enough to use a DataTable Object instead of a DataSet '***And now lets fill it! OleDbDataAdapter.Fill(DT) '***we don't need the connection to be open longer, so lets close it. oOleDbConnection.Close() '***it will be better to give a Name to the DataTable.... DT.TableName="Customer" '***lets bind the DataTable to a DataGridView DGV.DataSource=DT '***Thats all! This should work! Else Call MsGBox("Connection not open!") End If