473,805 Members | 2,164 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Limiting fetched rows with OleDbConnection

I'm using an OleDbConnection object to read a text file. It works
fine but what I really want to do is read a small sample from a very
large file. I'm looking for a way to limit the number of lines read
from the file.

I thought there might be something in the Extended Properties of the
connection string but can't find anything. I searched the online help
for "Extended Properties" and couldn't find a blasted thing.

Any help would be much appreciated.

Gene in NC

Nov 20 '05 #1
2 1633
Hi Gene,

Generally, I use a streamreader to read through a text file and then I
extract data in segments from it. However, your question suggests you're
using a text driver. If this is so, couldn't you limit the read with
'select top 25 etc?

HTH,

Bernie Yaeger
"Gene Hubert" <gw******@hotma il.com> wrote in message
news:3f******** ********@news-server.nc.rr.co m...
I'm using an OleDbConnection object to read a text file. It works
fine but what I really want to do is read a small sample from a very
large file. I'm looking for a way to limit the number of lines read
from the file.

I thought there might be something in the Extended Properties of the
connection string but can't find anything. I searched the online help
for "Extended Properties" and couldn't find a blasted thing.

Any help would be much appreciated.

Gene in NC

Nov 20 '05 #2
Hello,

"Gene Hubert" <gw******@hotma il.com> schrieb:
I'm using an OleDbConnection object to read a text file. It works
fine but what I really want to do is read a small sample from a very
large file. I'm looking for a way to limit the number of lines read
from the file.


Why don't use the functions contained in the 'System.IO' namespace to read
the file?

Basic code for reading the lines of a file:

\\\
Imports System.IO
..
..
..
Dim sr As New StreamReader("C :\WINDOWS\WIN.I NI")
Dim strLine As String
strLine = sr.ReadLine()
Do Until strLine Is Nothing
MsgBox(strLine)
strLine = sr.ReadLine()
Loop
sr.Close()
///

You can extend the sample by adding a line counter and stop reading after
reading n lines.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #3

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

Similar topics

6
506
by: Mark | last post by:
I get an error message when deleting rows from a table in Access database. My understanding is that the error message relates to the sharing of the Inetpub and the wwwroot directory. While I have set the directories to "Share" in the properties window, it still does not allow row removal. I'm running Microsoft Windows XP, Professional, Version 2002, Service Pack 1.
2
2436
by: nzanella | last post by:
Hello, I am running SQL Server 2000. I would like to know whether Microsoft Transact-SQL has a method for limiting the result set from a query in a way analogous to MySQL's LIMIT keyword, so that, for instance, if the result set contains 10,000 rows, then only the first 10 rows from the record set are output. Thank you,
1
13449
by: BF | last post by:
Hello, I am trying to find out if there is a way to limit the number of rows returned when a cursor is opened. I am using DB2 version 7 on z/OS. The SELECT statement in my DECLARE CURSOR statement could potentially return 400,000+ rows, but I really only want the first 15 records found. I can put a lower-bound (col >= "xxx") in the WHERE clause but cannot specify an upper-bound (i.e. AND col <= "yyy"); therefore, depending on the value...
2
3748
by: Mattyw | last post by:
Hi I have a sqlcommand that returns all the rows in a column and then pass that to a datareader. I am new to VS.Net and so far I can only return the first row in the first column using label1.text = reader(0).tostring
4
3217
by: Andre | last post by:
I am ruinning this in the global.asa VIA Visual Studio VB .NET (framework 1.1) I have a access database with a table called tblCounters with a feild called Counters with on row of data in it with a number. When I run the following code Imports System.Data Imports System.Data.OleDb Sub Session_Start......
2
3204
by: saraDotNet | last post by:
Hi everybody,I’v a question in a Vb.Net 2003 program,How can save or(insert) all the rows that I fill in a datagrid to be saved in itis datasource(table)at one time ,because my insertion code just save and insert the row where the curser is on it.So,IS there a solution. With thanks, here is my code, Imports System.Data.OleDb Public Class Form7 Inherits System.Windows.Forms.Form Private Sub Button1_Click(ByVal sender As System.Object,...
0
889
by: Paczek | last post by:
Hi, My name is Łukasz I from Poland;] Need Your's help This is code in C# : private void button4_Click(object sender, System.EventArgs e) { string strConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\MobileBook.mdb";
3
1506
by: Ifoel | last post by:
Hi all pls help me How to know "HOW MANY SECOND" we fetched the rows of the record MySQL via Visual Basic 6...? Sample: 321 rows Fetched in 0,234s -> i need this field to load on the FORM VB thanks in advance
1
14058
by: preejith | last post by:
Error Code : 1329, No data - zero rows fetched, selected, or processed. MYSQL I am getting the following error while running a stored procedure in mysql5.0 Error Code : 1329 No data - zero rows fetched, selected, or processed. I have an stored procedure SP1 which calls stored procedure SP2 and SP2 calls a function F1. I have run this script from .bat file.
0
9596
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10368
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
10107
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9186
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...
1
7649
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5544
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...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3846
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
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.