|
-
Jan 26th, 2009, 06:48 PM
#1
Thread Starter
Hyperactive Member
[2008] recordset question
i have a csv file. I read that csv in a recordset using the following code:
recordset = CreateObject("ADODB.Recordset")
recordset.Fields.append("F", 200, 255)
recordset.Fields.append("P", 200, 255)
recordset.open()
....
....
recordset.AddNew()
recordset("F") = arrText(0)
recordset("P") = arrText(1)
....
....
what i want is to create two other recordsets and put in there from the original recordset (query)
Dim rs = CreateObject("ADODB.recordset")
Dim Sql = "SELECT * FROM [table]"
rs.Open(Sql, csvrecordset)
MsgBox(rs.Recordcount)
rs.Close()
and then again with a different query to the third recordset.
i think it can be done this way. . but how can i define [table] in my original recordset?
-
Jan 26th, 2009, 07:09 PM
#2
Re: [2008] recordset question
First of all, is there a particular reason you are using ADO (which is basically for VB6, aka VB1998) rather than ADO.Net (which is designed for VB.Net)?
There are several articles in the "VB.Net" section of our Database Development FAQs/Tutorials (at the top of the Database Development forum) that explain how to use it.
Next, I may have misunderstood what you are trying to achieve, but it seems to me that you want to load the CSV data and put it into two database tables.
If so, why ask the database to send you data? It would be more efficient to simply add the items instead - as shown in post #3 of the article "Retrieving and Saving Data in Databases" (there is a link to it in the FAQs).
If not, what are you trying to achieve?
-
Jan 27th, 2009, 03:53 AM
#3
Thread Starter
Hyperactive Member
Re: [2008] recordset question
Thanks for your reply and the helpfull link .. no reason to use ado instead of ado.net .. gonna switch
i want indeed to load every row in a csv file into several databases based on a few criteria (creating buckets). After that i want to output those databases back to a csv file. So the data is the same only a different order. Sorting the data (which is in 1 dabasebase) is not sufficient.
or is there a better way? i want rows with a certain valuerange and a datarange to be on top. creatings a few ranges
is it better to make a connectionstring to the csv file .. or to read the textfile and use a textarray/split and then fill the several buckets
Last edited by Amien; Jan 27th, 2009 at 04:10 AM.
-
Jan 27th, 2009, 12:02 PM
#4
Re: [2008] recordset question
 Originally Posted by Amien
i want indeed to load every row in a csv file into several databases based on a few criteria (creating buckets). After that i want to output those databases back to a csv file. So the data is the same only a different order. Sorting the data (which is in 1 dabasebase) is not sufficient.
or is there a better way? i want rows with a certain valuerange and a datarange to be on top. creatings a few ranges
It's hard to tell quite what you mean.. could you show us using some example data?
Also, do you actually want the data to be stored in those other databases afterwards, or is this just to generate the final CSV file?
is it better to make a connectionstring to the csv file .. or to read the textfile and use a textarray/split and then fill the several buckets
It depends on the quality of the CSV file - unfortunately not all programs create them in quite the same way.
If it has been created properly, using it as a database is fine - but if it hasn't you are likely to get data type issues, so writing code to parse the file (which could take a while) would be a better idea.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|