473,738 Members | 2,645 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Que ryTables.Add(Co nnection:="URL; _
http://www.microsoft.c om", Destination:=Ra nge("A1"))
.Name = "www.micros oft"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFo rmulas = False
.PreserveFormat ting = True
.RefreshOnFileO pen = False
.BackgroundQuer y = True
.RefreshStyle = xlInsertDeleteC ells
.SavePassword = False
.SaveData = True
.AdjustColumnWi dth = True
.RefreshPeriod = 0
.WebSelectionTy pe = xlSpecifiedTabl es
.WebFormatting = xlWebFormatting None
.WebTables = """nTable"" "
.WebPreFormatte dTextToColumns = True
.WebConsecutive DelimitersAsOne = True
.WebSingleBlock TextImport = False
.WebDisableDate Recognition = False
.WebDisableRedi rections = False
.Refresh BackgroundQuery :=False
End With
End Sub

Nov 21 '05 #1
3 7248
Hi,

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

Ken
------------------
"MJ" <no**@nomail.co m> wrote in message
news:us******** *****@tk2msftng p13.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.Que ryTables.Add(Co nnection:="URL; _
http://www.microsoft.c om", Destination:=Ra nge("A1"))
.Name = "www.micros oft"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFo rmulas = False
.PreserveFormat ting = True
.RefreshOnFileO pen = False
.BackgroundQuer y = True
.RefreshStyle = xlInsertDeleteC ells
.SavePassword = False
.SaveData = True
.AdjustColumnWi dth = True
.RefreshPeriod = 0
.WebSelectionTy pe = xlSpecifiedTabl es
.WebFormatting = xlWebFormatting None
.WebTables = """nTable"" "
.WebPreFormatte dTextToColumns = True
.WebConsecutive DelimitersAsOne = True
.WebSingleBlock TextImport = False
.WebDisableDate Recognition = False
.WebDisableRedi rections = 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.Visua lBasic.FileIO.T extFieldParser]

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

"Ken Tucker [MVP]" <vb***@bellsout h.net> wrote in message
news:OE******** ******@TK2MSFTN GP12.phx.gbl...
Hi,

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

Ken
------------------
"MJ" <no**@nomail.co m> wrote in message
news:us******** *****@tk2msftng p13.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.Que ryTables.Add(Co nnection:="URL; _
http://www.microsoft.c om", Destination:=Ra nge("A1"))
.Name = "www.micros oft"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFo rmulas = False
.PreserveFormat ting = True
.RefreshOnFileO pen = False
.BackgroundQuer y = True
.RefreshStyle = xlInsertDeleteC ells
.SavePassword = False
.SaveData = True
.AdjustColumnWi dth = True
.RefreshPeriod = 0
.WebSelectionTy pe = xlSpecifiedTabl es
.WebFormatting = xlWebFormatting None
.WebTables = """nTable"" "
.WebPreFormatte dTextToColumns = True
.WebConsecutive DelimitersAsOne = True
.WebSingleBlock TextImport = False
.WebDisableDate Recognition = False
.WebDisableRedi rections = 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("fieldn ame1") = 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
7301
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 running. I prefer not to. I just need Python components for local consumption in other languages. I remember Gnome libs having some thing like this. Any thoughts?
2
3279
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. Javascritp has >>> and >>. >>> is a zero fill bit shift whereas >> is a sign propagating bit shift. My understanding is that the python >> is equivalent to the javascript >> - but python has no equivalent to >>>. Would a >>> 3 in javascript be...
3
2297
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 ordinary Lisp S-expression. So it's easy enough to translate some XML into equivalent Lisp. Now I turn it over to the Lisp parser, which creates the equivalent of the DOM for me.
1
3813
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 presentation styles and different data sources. Presentation styles like tabular format , graph format, grid format, freeform format, Composite format(somthing
6
5168
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 controls do a JNDI lookup to invoke methods on EJB's. The EJB's use local Java classes, and these classes use JDBC to do database work. Example: Login.jsp contains "import xxx.LoginControl", and invokes the "login"
3
3155
by: Marty | last post by:
Hi, What is the VB.NET equivalent of the VB6 ADODB.Connector and ADODB.Recordset? Thanks Marty
7
3726
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 : String;
10
7330
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
4049
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 equivalent. Is there such a function available in C#? I can see that VB.NET has one, but I couldn't see how to get at it in C#. For example, if I have ...
14
2550
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 both statements are similar : *((char **)v)++ == *((char **)v++) Where v is a pointer to an array of characters,defined as char *v;
0
9473
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9334
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9259
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8208
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6053
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4569
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3279
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2193
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.