How to fill Records from excel sheet into Datagrid..!

strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:data.xls;Extended Properties=""Excel 8.0;HDR=NO;"""

objConn =

New OleDb.OleDbConnection(strConn)


‘sql = "SELECT Project Name FROM [Data$]"

Sql = "SELECT * FROM [Data$]"

Dim objCommand As New OleDb.OleDbCommand(sql, objConn)

Dim objAdapter As New OleDb.OleDbDataAdapter(objCommand)

Dim objDS As New DataSet


‘CbProjectName.DataSource = objDS.Tables(0).DefaultView

‘CbProjectName.DisplayMember = objDS.Tables(0).Columns(1).ColumnName

‘CbProjectName.ValueMember = objDS.Tables(0).Columns(0).ColumnName

Dim dr As DataRow ‘ This code removes empty rows from DataSet

For Each dr In objDS.Tables(0).Rows

If (dr.IsNull(0)) And (dr.IsNull(1)) Then


End If


DataGridView1.DataSource = objDS.Tables(0).DefaultView


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: