View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
byronem byronem is offline
external usenet poster
 
Posts: 1
Default Help request for vb .net in excel

kh,

Unfortunately, you'll need to use VBA or macros to do what you want.
Selects are easy with ADO.NET, but inserts are another matter altogether. I
have no idea how to do that. Try posting to one of the VBA boards. Good
luck!

"kh" wrote:

Hi
Yes please let me know how to query data. For example, after reading data
A2:A10 , I wish to paste them in cells H2:H10 same sheet. I wish to know each
item of theses data as array, to be manipulated easily.
Many thanks for your time.
Best Regards,
kh

"campwes" wrote:

Here ya go:

Dim dbConn As OleDbConnection
Dim strConn As String
Dim strSQL As String
Dim rdr As OleDbDataReader

strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=FileName.xls;Extended Properties=""Excel 8.0;IMEX=1"""
dbConn = New OleDbConnection(strConn)
dbConn.Open()

Dim cmd As OleDbCommand = dbConn.CreateCommand()
cmd.CommandText = " select * from [Sheet1$A2:A10] "
rdr = cmd.ExecuteReader()

Let me know if you need help with how to output the data from the query.

Cheers,