Varshini S
asked on
VB.NET Application throwing an error - Public member 'ExecuteReader' on type 'applicationClass' not found.
when i execute the following code i got this exception
Public member 'ExecuteReader' on type 'applicationClass' not found. How do i fix this ?
Public member 'ExecuteReader' on type 'applicationClass' not found. How do i fix this ?
Imports Excel = Microsoft.Office.Interop.Excel
Imports System.Data.SqlClient
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim xl As New Microsoft.Office.Interop.Excel.Application
Dim wSheet As Excel.Worksheet
xl.Workbooks.Open("C:\TEMP\ITEM.CSV")
wSheet = xl.Workbooks("ITEM.CSV").Sheets("ITEM")
'all your data objects here like connection and command
Dim dr As SqlDataReader
Try
dr = xl.ExecuteReader
If dr.HasRows Then
While dr.Read()
wSheet.Cells(1, 1) = dr.Item("SomeColumnName")
wSheet.Cells(1, 2) = dr.Item("SomeOtherColumnName")
End While
End If
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Wayne Taylor (webtubbs) : i would like to read excel sheet and assign the values to data reader.
ASKER
Wayne Taylor (webtubbs) : i would like to read excel sheet and assign the values to data reader. i would like to use ADO.Net.
Is there a good reason why you want to use ADO.NET instead of going straight to Excel as you could do by using your wSheet variable with stuff such as wSheet.Cells(3,5).Value?
ASKER
Reason for using ADO.NET is want to assign the cell values to data reader object.
What is it you are trying to do?