Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
kh kh is offline
external usenet poster
 
Posts: 8
Default Help request for vb .net in excel

Hi evry one,
I have an excel file which contain group of cells from A2 to A10, those
cell values are changing almost each 10 seconds. Any one can help me how to
read those values in visual basic studio .net 2003. The excel file is always
open, I do not need to open it, I need to define this file and read the cell
values in my vb studio.
Help please.
Kh
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Help request for vb .net in excel

kh,

You can use an OleDbDataReader (ADO.NET) and query the cells in your range:

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

Use Console.WriteLine() or whatever to output the data where you need.

Ciao,
  #3   Report Post  
Posted to microsoft.public.excel.programming
kh kh is offline
external usenet poster
 
Posts: 8
Default Help request for vb .net in excel

Hi
Thank you for your time, appreciated.
Please write to me the complete code, because the lines you wrote are not
working. I am using visual studio vb 2005. Thank you.
Best Regards,
kh

"campwes" wrote:

kh,

You can use an OleDbDataReader (ADO.NET) and query the cells in your range:

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

Use Console.WriteLine() or whatever to output the data where you need.

Ciao,

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Help request for vb .net in excel

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,


  #5   Report Post  
Posted to microsoft.public.excel.programming
kh kh is offline
external usenet poster
 
Posts: 8
Default Help request for vb .net in excel

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,




  #6   Report Post  
Posted to microsoft.public.excel.programming
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,


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel formula request Stan Excel Worksheet Functions 1 January 14th 10 06:51 AM
Using SQLRequest with Excel 2003 Larry Gomez Excel Discussion (Misc queries) 1 July 25th 08 05:06 PM
Excel 2007: request for help newscientist Excel Worksheet Functions 0 July 16th 07 09:38 AM
Does SQL.REQUEST work in Excel X? mrl Excel Discussion (Misc queries) 5 February 4th 05 08:36 PM
Excel help request Mark Excel Programming 3 May 20th 04 01:26 PM


All times are GMT +1. The time now is 11:57 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"