Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / Database Access / February 2005



Tip: Looking for answers? Try searching our database.

input text file to make query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kate - 25 Feb 2005 07:49 GMT
Hello!

I want to do a batch query reading the criteria from a text file.  The query
should return in one recordset, and the result will be saved in another text
file.  I'm using array to read the input file, but it returns in more then
one recordsets... then the output file turns out to has only one record (the
last value in the input file).  

Here's my code:        
       ConnSRdb  'connect to db
       
       Dim qFile As String
       qFile = txtSearchbyBatch.Text
       Dim sField
       Open qFile For Input As #2
       
       Dim sData() As String
       Dim Count As Integer
       Count = 0
       
       Do While Not EOF(2)
           Input #2, sField
           ReDim Preserve sData(Count)
           sData(Count) = sField
           CommandText = "select mslink, slope_no, status, reg_date from
slp_feature where " & _
           "" & cboSearchby2.Text & " = '" & sData(Count) & "'"
           Set queryRs = sdoConn.Execute(CommandText)
           Count = Count + 1
       Loop
       Exportcsv queryRs, exportPath  'save result into a text file.
       Close #2

Can anyone tell me how to put all results into one recordset?

Thanks!
Kate
Val Mazur - 26 Feb 2005 02:15 GMT
Hi Kate,

What you need to do is to use Jet OLEDB provider to load data from the text
file into ADO recordset. It is much simpler and it is more elegant. You
could also specify datatypes for your columns in this case and use SELECT
SQL statement to select data from the file. One thing you should consider in
this case is you have to create Schema.ini file to be able to load data into
ADO recordset. You could create this file dynamically from  your application
or you could do it manually once if structure of your source text file is
static. See next link with the examples how to do all this staff.If you need
additional help let me know

http://support.microsoft.com/default.aspx?scid=kb;en-us;326548 (Go to the
bottom of the article and see how to open connection to the file and how to
query it)

http://support.microsoft.com/default.aspx?scid=kb;en-us;210001

Signature

Val Mazur
Microsoft MVP

http://xport.mvps.org

> Hello!
>
[quoted text clipped - 36 lines]
> Thanks!
> Kate
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.