473,409 Members | 2,063 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

VB.NET equivalent for Excel's [Data>ImportData>WebQuery]

MJ
Is there a VB.NET (1.1 or 2.0) equivalent for Excel's
[Data>ImportData>WebQuery]?

Below is a copy of an example of the Excel VBA that I have been using to
pull some data off a webpage. I've got a couple of simple application that
currently live in an Excel workbook as VBA solely for this one function.

I'd like to move this to a VB.NET Windows form application that does not
rely on Excel.
Example of Excel VBA:

Sub GetData()
With ActiveSheet.QueryTables.Add(Connection:="URL; _
http://www.microsoft.com", Destination:=Range("A1"))
.Name = "www.microsoft"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = """nTable"""
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub

Nov 21 '05 #1
3 7229
Hi,

http://www.windowsformsdatagridhelp....f-56dbb63fdf1c

Ken
------------------
"MJ" <no**@nomail.com> wrote in message
news:us*************@tk2msftngp13.phx.gbl...
Is there a VB.NET (1.1 or 2.0) equivalent for Excel's
[Data>ImportData>WebQuery]?

Below is a copy of an example of the Excel VBA that I have been using to
pull some data off a webpage. I've got a couple of simple application that
currently live in an Excel workbook as VBA solely for this one function.

I'd like to move this to a VB.NET Windows form application that does not
rely on Excel.
Example of Excel VBA:

Sub GetData()
With ActiveSheet.QueryTables.Add(Connection:="URL; _
http://www.microsoft.com", Destination:=Range("A1"))
.Name = "www.microsoft"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = """nTable"""
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub

Nov 21 '05 #2
MJ
Thanks Ken.

That seems to work, but I do have a follow-up question.

My overall objective is to get the information in a table on a webpage into
a table in a dataset.

Using the example you gave me, I modified the stringbuilder code to build a
comma-delimited string of the data I want. Save that to a text file, then
read that text file into the dataset table using
[Microsoft.VisualBasic.FileIO.TextFieldParser]

Just wondering if I'm doing this the hard way or if there is a better way.
MJ

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:OE**************@TK2MSFTNGP12.phx.gbl...
Hi,

http://www.windowsformsdatagridhelp....f-56dbb63fdf1c

Ken
------------------
"MJ" <no**@nomail.com> wrote in message
news:us*************@tk2msftngp13.phx.gbl...
Is there a VB.NET (1.1 or 2.0) equivalent for Excel's
[Data>ImportData>WebQuery]?

Below is a copy of an example of the Excel VBA that I have been using to
pull some data off a webpage. I've got a couple of simple application
that currently live in an Excel workbook as VBA solely for this one
function.

I'd like to move this to a VB.NET Windows form application that does not
rely on Excel.
Example of Excel VBA:

Sub GetData()
With ActiveSheet.QueryTables.Add(Connection:="URL; _
http://www.microsoft.com", Destination:=Range("A1"))
.Name = "www.microsoft"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlInsertDeleteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlSpecifiedTables
.WebFormatting = xlWebFormattingNone
.WebTables = """nTable"""
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub


Nov 21 '05 #3
MJ,

Just wondering if I'm doing this the hard way or if there is a better way.

Yes that is the hard way.

In all our samples with datasets we use 3 methods.
The Northwind SQLServer sample
The Northwind Access sample database
Building direct the dataset/datatable by code

The last is in my opinion easier for you to do.

Here is a short sample, have only a look at the building in the bottom.

http://www.windowsformsdatagridhelp....3-a3539697edbd

There are more, however the principle is the same.
Instead of loading the row, you have to do

dt.rows.add(dt.newrow)
and than
dt.rows("fieldname1") = tagfield
etc.

There are samples about that as well on our site, however I took a short one
to show how simple it is.

I hope this helps,

Cor
Nov 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: John | last post by:
Is there an equivalent of COM on Linux that I can get through Python. My need is to have some sort of language independent component framework. I can think of CORBA but I have to have a server...
2
by: Michael Foord | last post by:
Please pardon my ignorance on this one - but I'm not certain how the sign bt is treated in python bitwise operators. I've trying to convert a javascript DES encryption routine into python. ...
3
by: Robert Dodier | last post by:
Hello, Here's a thought that I'm sure has already occurred to someone else, I just can't find any record of it yet. An XML document is just a more verbose and clumsy representation of an...
1
by: Vannela | last post by:
Is there any equivalent control in .NET for the Power builder DataWindow control? I am explaining the Datawindow architecture to some extent. Power Builder DataWindow Control has got different...
6
by: Frank Rachel | last post by:
So I can focus on the correct areas of research, I was wondering if someone could give me the .NET equivelents for this J2EE architecture: JSP's make calls to local JavaBean Controls. The...
3
by: Marty | last post by:
Hi, What is the VB.NET equivalent of the VB6 ADODB.Connector and ADODB.Recordset? Thanks Marty
7
by: Tim Conner | last post by:
Hi, I am an ex-delphi programmer, and I having a real hard time with the following simple code (example ): Which is the equivalent to the following code ? var chars : PChar; sBack, s :...
10
by: karch | last post by:
How would this C# contruct be represented in C++/CLI? Or is it even possible? PolicyLevel level = (enumerator->Current) as PolicyLevel; Thanks, Karch
9
by: Alan Silver | last post by:
Hello, I'm converting some old VB6 code to use with ASP.NET and have come unstuck with the Asc() function. This was used in the old VB6 code to convert a character to its ASCII numeric...
14
by: grid | last post by:
Hi, I have a certain situation where a particular piece of code works on a particular compiler but fails on another proprietary compiler.It seems to have been fixed but I just want to confirm if...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.