This is a discussion on "importing txt file to SQL with recordset" within the Classic ASP section. This forum, and the thread "importing txt file to SQL with recordset are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
importing txt file to SQL with recordset
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
importing txt file to SQL with recordset
Im trying to import a ; spaced txt file to SQL with the help of recordsets in asp, and having some problems with a text field that is over 256 chars.
Can i use a substr in my select from the txt file? how? |
|
|
|
||||
|
Are you using the 'ODBC Driver for Text files' ?
__________________
Rob - SEO Specialist Owner & Founder of Webforumz.com I am currently unavailable for private work
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
|||
|
Conn.Open "Driver={Microsoft Text Driver (*.txt; *.csv)};" & _
"HDR=yes;" &_ "Dbq=C:\temp;" & _ "Extensions=asc,csv,tab,txt;" & _ "Persist Security Info=False" |
|
||||
|
You may need a schema.ini file....
It's worth investigating. I rarely use the text driver... and only then for csv files
__________________
Rob - SEO Specialist Owner & Founder of Webforumz.com I am currently unavailable for private work
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
|||
|
im am using a schema.ini.
All is working as it should but im missing the last chars from the text field that is over 256 chars, since the recordset can't hold more.... You know if the text driver suports substring select? |
|
||||
|
Can you post your code (in forum code tags) and a sample of your data?
I import records with longer fieldlengths with no issues. Also, please post your schema.ini file
__________________
Rob - SEO Specialist Owner & Founder of Webforumz.com I am currently unavailable for private work
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
|||
schema.ini: [Artikkeldata2.txt] Format=Delimited(;) ColNameHeader=True MaxScanRows=0 CharacterSet=ANSI the recordset works as it should exept for the filed from the txt file with over 255 chars. |
|
|||
|
i tryed to use a substing select to select the remainig of the filed, but dont know if the ODBC driver suports it...
|
|
||||
|
Can you post the first 10 lines of your text file? The data?
__________________
Rob - SEO Specialist Owner & Founder of Webforumz.com I am currently unavailable for private work
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
|||
|
"Doknr";"N1 Dokument Tittel";"N1 Kommentar Tittel";"N1 Revisjonstekst";"N1_Kommentar";"N2 Start Tekst";"N2 Slutt Tekst";"Varenummer";"Modellkode";"Mrp";"Nettovekt" ;"Basispris";"Attributt";"Beskrivelse";"Alfanumeri sk";"Numerisk";"Fys Beh";"Av Doknr";"Av Dokument Tittel"
111001-1-1;Tannhjulspumpe - Marzocchi - GHP;Tannhjulspumper serie GHP1, GHP2 og GHP3;Pumpene er enkle, robuste og rimelige. Kan monteres sammen med BORELLI forsatslager, elektrisk og manuell frikobling.;#Arbeidstrykk opptil 290bar. #Fortregningsvolum 1,4-52 cm3/r #Tandempumper fra lager #Høyregående som standard #Dreieretning skiftes enkelt #Standard aksling er Kon 1:8;;;GHP1D2;GHP1D2;A;;1610;P01;Trykk bar kont.;;290;21;111001-1-1-1;Tannhjulspumpe - Marzocchi - GHP - Datablad 111001-1-1;Tannhjulspumpe - Marzocchi - GHP;Tannhjulspumper serie GHP1, GHP2 og GHP3;Pumpene er enkle, robuste og rimelige. Kan monteres sammen med BORELLI forsatslager, elektrisk og manuell frikobling.;#Arbeidstrykk opptil 290bar. #Fortregningsvolum 1,4-52 cm3/r #Tandempumper fra lager #Høyregående som standard #Dreieretning skiftes enkelt #Standard aksling er Kon 1:8;;;GHP1D2;GHP1D2;A;;1610;P01;Trykk bar kont.;;290;21;111001-1-1-2;Tannhjulspumpe - Marzocchi - GHP - Artikkeltabell 111001-1-1;Tannhjulspumpe - Marzocchi - GHP;Tannhjulspumper serie GHP1, GHP2 og GHP3;Pumpene er enkle, robuste og rimelige. Kan monteres sammen med BORELLI forsatslager, elektrisk og manuell frikobling.;#Arbeidstrykk opptil 290bar. #Fortregningsvolum 1,4-52 cm3/r #Tandempumper fra lager #Høyregående som standard #Dreieretning skiftes enkelt #Standard aksling er Kon 1:8;;;GHP1D2;GHP1D2;A;;1610;P02;Trykk bar int.;;300;21;111001-1-1-1;Tannhjulspumpe - Marzocchi - GHP - Datablad 111001-1-1;Tannhjulspumpe - Marzocchi - GHP;Tannhjulspumper serie GHP1, GHP2 og GHP3;Pumpene er enkle, robuste og rimelige. Kan monteres sammen med BORELLI forsatslager, elektrisk og manuell frikobling.;#Arbeidstrykk opptil 290bar. #Fortregningsvolum 1,4-52 cm3/r #Tandempumper fra lager #Høyregående som standard #Dreieretning skiftes enkelt #Standard aksling er Kon 1:8;;;GHP1D2;GHP1D2;A;;1610;P02;Trykk bar int.;;300;21;111001-1-1-2;Tannhjulspumpe - Marzocchi - GHP - Artikkeltabell |
|
||||
|
Here is the connectionstring I use:-
__________________
Rob - SEO Specialist Owner & Founder of Webforumz.com I am currently unavailable for private work
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
||||
|
If the above doesnt work, then I have a plan.
__________________
Rob - SEO Specialist Owner & Founder of Webforumz.com I am currently unavailable for private work
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
|||
|
:P whats ur plan ?
|
|
||||
|
ok.... read in the entire file to a string using the file system object.
Use the Split command to split the string using VBCRLF. This will give an array of records. Split each record on the semicolon. This will then give an array of fields. User constants to represent fieldnames:- Doknr = 0 Dokument_Tittel = 1 Kommentar_Titte=2 Revisjonstekst = 3 ... etc Then just refer to the array using the constants:- FieldArray(Doknr) wil return the info needed. I hope this makes sense. If not, post back and I'll will post up some code.
__________________
Rob - SEO Specialist Owner & Founder of Webforumz.com I am currently unavailable for private work
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
|||
|
could prob make it my self, but always love a code example if u got 1
|
|
||||
|
I aint got one handy... but if you get stuck, let me know.
__________________
Rob - SEO Specialist Owner & Founder of Webforumz.com I am currently unavailable for private work
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
|||
|
and btw when i try to use
Microsoft JET Database Engine (0x80004005) Could not find installable ISAM. how do i fix this? |
|
||||
|
Never seen this before.
From what I can find out, you should look here:- http://support.microsoft.com/kb/209805 Check out the resolution (for the text driver) That should help. THe workaround method I described above is fairly easy and would likely be much quicker than ODBC anyway. Arrays are lightning quick in ASP.
__________________
Rob - SEO Specialist Owner & Founder of Webforumz.com I am currently unavailable for private work
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
||||
|
Try this code I just flung together:-
__________________
Rob - SEO Specialist Owner & Founder of Webforumz.com I am currently unavailable for private work
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
|
||||
|
you getting anywhere with this?
__________________
Rob - SEO Specialist Owner & Founder of Webforumz.com I am currently unavailable for private work
Last Blog Entry: Creative Labs threaten developer over home made drivers.... (Apr 1st, 2008)
|
![]() |
| Tags |
| importing, txt, file, sql, recordset |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| recordset/table display | Eclipse414 | Web Page Design | 4 | Dec 25th, 2005 21:02 |
| Importing RecordSet to .asp file | tolis | Classic ASP | 8 | Nov 23rd, 2005 20:23 |
| ADODB.Recordset error '800a0bb9' | grittyminder | Databases | 2 | Jul 15th, 2005 21:09 |
| passing recordset to next page? | Monie | Classic ASP | 1 | Sep 25th, 2004 07:53 |
| recordset constants (data types) | spinal007 | Classic ASP | 6 | Sep 19th, 2004 07:39 |