I am not able to display dataset. Can anyone help me out?
Here is my code:

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

Public Class Form3
Inherits System.Windows.Forms.Form
Private WithEvents DataGridView1 As New DataGridView

Private Sub Currdbbtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Currdbbtn.Click
Dim objConnection As New OleDb.OleDbConnection
objConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source= C:\Documents and settings\ambarda\My Documents\Sampledatabase.mdb;"
Dim ds As New DataSet
Dim sql As String = "SELECT * FROM Sheet1"
Dim objDataAdapter As New OleDb.OleDbDataAdapter(sql, objConnection)
objDataAdapter.Fill(ds, "Runsheet Info")
DataGridView1.DataSource = ds.DefaultViewManager
End sub
End class


I am not able to view dataset. Any help and suggestions appreciated.
Thanks in advance.
Aditya

Im not sure about this, but I think the "Runsheet Info" should be the table name that you are pulling from. According to your SQL the table is "Sheet1". Now, again I'm not sure about this, but it is something simple to try and it might fix your problem...

It seems you have created the DataGridView at runtime through code.

When you add a control at runtime through code-you have to add the control to the Forms control Collection as below:

Me.Controls.Add (DataGridView1)

Add this either in the Form_Load Event or the Buttons Click event.

Hope this helps.

Regards
Sunil Punjabi
<snipped url>

Yes you are right, I realizd my mistake, I did not add as a control in the form. That was the problem.
Thank you guys.
Aditya

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.