Welcome to the { mindfrost82.com } forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Go Back   { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Programming > ASP.NET

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-23-2003, 08:28 PM
Brian Henry
 
Posts: n/a
Re: Read from a textfile and save in database

fix your date then maybe someone will help you first..


"[ F e r n a n d o L o p e s ]" <lospe_remove_this_@spacnet.com.br> wrote in
message news:eMg5W$YmDHA.3320@tk2msftngp13.phx.gbl...
> Hello ALL,
> I need to read data from a .txt file and save this data in a sql server
> database table.
> The .txt file format like this:
> -----------------------------------------------------------
> 01851L. D. DISTRIBUIDORA DE S. M. LTDA L. D. DISTRIBUIDORA
> 73765034000140102622574 10008AV. ANHANGUERA,
> 02469NICOLAS BARREIRA GONZALES NICOLAS BARREIRA
> 56599749000151336206241110 10013RUA SISA, 465
>
> And the I need to pass to database table like this:
> Table Customers
> -------------------------------------------
> IdCustomer - 01851
> FullName - L. D. DISTRIBUIDORA DE S. M. LTDA
> ShortName - L. D. DISTRIBUIDORA
> CurrNo - 73765034000140102622574
> SpNo - 10008
> Address - AV. ANHANGUERA
>
>
> Well, I know I guess use StreamReader to read the .txt file no?
> StreaReader x = new StreamReader("C:\\data.txt");
> But I need some help with the logic, the loop, to do this code.
>
> Anyboy help me?
>
> Thanks in advance and sorry my English.
>
> Fernando Lopes
> São Paulo - Brasil
>
>



Reply With Quote
  #2 (permalink)  
Old 10-23-2003, 09:35 PM
zPaul
 
Posts: n/a
Re: Read from a textfile and save in database

The logic is you read a line and chop it out according to the position of
each type of data. For LDCustomer, you will get substring of 0 to 4 etc..

"Brian Henry" <brianiup@adelphia.net> wrote in message
news:e$SfOvZmDHA.1800@TK2MSFTNGP10.phx.gbl...
> fix your date then maybe someone will help you first..
>
>
> "[ F e r n a n d o L o p e s ]" <lospe_remove_this_@spacnet.com.br> wrote

in
> message news:eMg5W$YmDHA.3320@tk2msftngp13.phx.gbl...
> > Hello ALL,
> > I need to read data from a .txt file and save this data in a sql server
> > database table.
> > The .txt file format like this:
> > -----------------------------------------------------------
> > 01851L. D. DISTRIBUIDORA DE S. M. LTDA L. D. DISTRIBUIDORA
> > 73765034000140102622574 10008AV. ANHANGUERA,
> > 02469NICOLAS BARREIRA GONZALES NICOLAS BARREIRA
> > 56599749000151336206241110 10013RUA SISA, 465
> >
> > And the I need to pass to database table like this:
> > Table Customers
> > -------------------------------------------
> > IdCustomer - 01851
> > FullName - L. D. DISTRIBUIDORA DE S. M. LTDA
> > ShortName - L. D. DISTRIBUIDORA
> > CurrNo - 73765034000140102622574
> > SpNo - 10008
> > Address - AV. ANHANGUERA
> >
> >
> > Well, I know I guess use StreamReader to read the .txt file no?
> > StreaReader x = new StreamReader("C:\\data.txt");
> > But I need some help with the logic, the loop, to do this code.
> >
> > Anyboy help me?
> >
> > Thanks in advance and sorry my English.
> >
> > Fernando Lopes
> > São Paulo - Brasil
> >
> >

>
>



Reply With Quote
  #3 (permalink)  
Old 10-24-2003, 07:32 AM
Gilad Goldberg
 
Posts: n/a
Re: Read from a textfile and save in database

I would use StringReader to read the line, not substring. Cleaner, i
believe.

"zPaul" <~pyoon@phnip.com> wrote in message
news:eEqwjUamDHA.1708@TK2MSFTNGP12.phx.gbl...
> The logic is you read a line and chop it out according to the position of
> each type of data. For LDCustomer, you will get substring of 0 to 4 etc..
>
> "Brian Henry" <brianiup@adelphia.net> wrote in message
> news:e$SfOvZmDHA.1800@TK2MSFTNGP10.phx.gbl...
> > fix your date then maybe someone will help you first..
> >
> >
> > "[ F e r n a n d o L o p e s ]" <lospe_remove_this_@spacnet.com.br>

wrote
> in
> > message news:eMg5W$YmDHA.3320@tk2msftngp13.phx.gbl...
> > > Hello ALL,
> > > I need to read data from a .txt file and save this data in a sql

server
> > > database table.
> > > The .txt file format like this:
> > > -----------------------------------------------------------
> > > 01851L. D. DISTRIBUIDORA DE S. M. LTDA L. D. DISTRIBUIDORA
> > > 73765034000140102622574 10008AV. ANHANGUERA,
> > > 02469NICOLAS BARREIRA GONZALES NICOLAS BARREIRA
> > > 56599749000151336206241110 10013RUA SISA, 465
> > >
> > > And the I need to pass to database table like this:
> > > Table Customers
> > > -------------------------------------------
> > > IdCustomer - 01851
> > > FullName - L. D. DISTRIBUIDORA DE S. M. LTDA
> > > ShortName - L. D. DISTRIBUIDORA
> > > CurrNo - 73765034000140102622574
> > > SpNo - 10008
> > > Address - AV. ANHANGUERA
> > >
> > >
> > > Well, I know I guess use StreamReader to read the .txt file no?
> > > StreaReader x = new StreamReader("C:\\data.txt");
> > > But I need some help with the logic, the loop, to do this code.
> > >
> > > Anyboy help me?
> > >
> > > Thanks in advance and sorry my English.
> > >
> > > Fernando Lopes
> > > São Paulo - Brasil
> > >
> > >

> >
> >

>
>



Reply With Quote
  #4 (permalink)  
Old 10-24-2003, 09:57 AM
Lasse Edsvik
 
Posts: n/a
Re: Read from a textfile and save in database

are you using access or sql server?

if sql server you can do a bulk insert with bcp

/Lasse


"[ F e r n a n d o L o p e s ]" <lospe_remove_this_@spacnet.com.br> wrote in
message news:eMg5W$YmDHA.3320@tk2msftngp13.phx.gbl...
> Hello ALL,
> I need to read data from a .txt file and save this data in a sql server
> database table.
> The .txt file format like this:
> -----------------------------------------------------------
> 01851L. D. DISTRIBUIDORA DE S. M. LTDA L. D. DISTRIBUIDORA
> 73765034000140102622574 10008AV. ANHANGUERA,
> 02469NICOLAS BARREIRA GONZALES NICOLAS BARREIRA
> 56599749000151336206241110 10013RUA SISA, 465
>
> And the I need to pass to database table like this:
> Table Customers
> -------------------------------------------
> IdCustomer - 01851
> FullName - L. D. DISTRIBUIDORA DE S. M. LTDA
> ShortName - L. D. DISTRIBUIDORA
> CurrNo - 73765034000140102622574
> SpNo - 10008
> Address - AV. ANHANGUERA
>
>
> Well, I know I guess use StreamReader to read the .txt file no?
> StreaReader x = new StreamReader("C:\\data.txt");
> But I need some help with the logic, the loop, to do this code.
>
> Anyboy help me?
>
> Thanks in advance and sorry my English.
>
> Fernando Lopes
> São Paulo - Brasil
>
>



Reply With Quote
  #5 (permalink)  
Old 10-24-2003, 02:10 PM
[ F e r n a n d o L o p e s ]
 
Posts: n/a
Re: Read from a textfile and save in database

Sorry about the date man.
I change to test some functions in one program and forgot.

"Brian Henry" <brianiup@adelphia.net> wrote in message
news:e$SfOvZmDHA.1800@TK2MSFTNGP10.phx.gbl...
> fix your date then maybe someone will help you first..
>
>
> "[ F e r n a n d o L o p e s ]" <lospe_remove_this_@spacnet.com.br> wrote

in
> message news:eMg5W$YmDHA.3320@tk2msftngp13.phx.gbl...
> > Hello ALL,
> > I need to read data from a .txt file and save this data in a sql server
> > database table.
> > The .txt file format like this:
> > -----------------------------------------------------------
> > 01851L. D. DISTRIBUIDORA DE S. M. LTDA L. D. DISTRIBUIDORA
> > 73765034000140102622574 10008AV. ANHANGUERA,
> > 02469NICOLAS BARREIRA GONZALES NICOLAS BARREIRA
> > 56599749000151336206241110 10013RUA SISA, 465
> >
> > And the I need to pass to database table like this:
> > Table Customers
> > -------------------------------------------
> > IdCustomer - 01851
> > FullName - L. D. DISTRIBUIDORA DE S. M. LTDA
> > ShortName - L. D. DISTRIBUIDORA
> > CurrNo - 73765034000140102622574
> > SpNo - 10008
> > Address - AV. ANHANGUERA
> >
> >
> > Well, I know I guess use StreamReader to read the .txt file no?
> > StreaReader x = new StreamReader("C:\\data.txt");
> > But I need some help with the logic, the loop, to do this code.
> >
> > Anyboy help me?
> >
> > Thanks in advance and sorry my English.
> >
> > Fernando Lopes
> > São Paulo - Brasil
> >
> >

>
>



Reply With Quote
  #6 (permalink)  
Old 10-24-2003, 02:24 PM
[ F e r n a n d o L o p e s ]
 
Posts: n/a
Re: Read from a textfile and save in database

Well, ok but, how can I do the loop.
I need help to write the logical code for get the data from de .txt file and
insert into the database
Is something like this?

StreamReader file = new StreamReader("C:\\data.txt");
for (int i=0;i<file.Lenght;i++)
{
Here i don´t know what am i do!!
}

Thanks.

Fernando Lopes


"zPaul" <~pyoon@phnip.com> wrote in message
news:eEqwjUamDHA.1708@TK2MSFTNGP12.phx.gbl...
> The logic is you read a line and chop it out according to the position of
> each type of data. For LDCustomer, you will get substring of 0 to 4 etc..
>
> "Brian Henry" <brianiup@adelphia.net> wrote in message
> news:e$SfOvZmDHA.1800@TK2MSFTNGP10.phx.gbl...
> > fix your date then maybe someone will help you first..
> >
> >
> > "[ F e r n a n d o L o p e s ]" <lospe_remove_this_@spacnet.com.br>

wrote
> in
> > message news:eMg5W$YmDHA.3320@tk2msftngp13.phx.gbl...
> > > Hello ALL,
> > > I need to read data from a .txt file and save this data in a sql

server
> > > database table.
> > > The .txt file format like this:
> > > -----------------------------------------------------------
> > > 01851L. D. DISTRIBUIDORA DE S. M. LTDA L. D. DISTRIBUIDORA
> > > 73765034000140102622574 10008AV. ANHANGUERA,
> > > 02469NICOLAS BARREIRA GONZALES NICOLAS BARREIRA
> > > 56599749000151336206241110 10013RUA SISA, 465
> > >
> > > And the I need to pass to database table like this:
> > > Table Customers
> > > -------------------------------------------
> > > IdCustomer - 01851
> > > FullName - L. D. DISTRIBUIDORA DE S. M. LTDA
> > > ShortName - L. D. DISTRIBUIDORA
> > > CurrNo - 73765034000140102622574
> > > SpNo - 10008
> > > Address - AV. ANHANGUERA
> > >
> > >
> > > Well, I know I guess use StreamReader to read the .txt file no?
> > > StreaReader x = new StreamReader("C:\\data.txt");
> > > But I need some help with the logic, the loop, to do this code.
> > >
> > > Anyboy help me?
> > >
> > > Thanks in advance and sorry my English.
> > >
> > > Fernando Lopes
> > > São Paulo - Brasil
> > >
> > >

> >
> >

>
>



Reply With Quote
  #7 (permalink)  
Old 10-24-2003, 02:25 PM
[ F e r n a n d o L o p e s ]
 
Posts: n/a
Re: Read from a textfile and save in database

Hello Lasse.
Sorry but, what is a bulk insert with bcp?

Thanks

Fernando Lopes

"Lasse Edsvik" <lasse@nospam.com> wrote in message
news:uFBSnxgmDHA.1708@TK2MSFTNGP12.phx.gbl...
> are you using access or sql server?
>
> if sql server you can do a bulk insert with bcp
>
> /Lasse
>
>
> "[ F e r n a n d o L o p e s ]" <lospe_remove_this_@spacnet.com.br> wrote

in
> message news:eMg5W$YmDHA.3320@tk2msftngp13.phx.gbl...
> > Hello ALL,
> > I need to read data from a .txt file and save this data in a sql server
> > database table.
> > The .txt file format like this:
> > -----------------------------------------------------------
> > 01851L. D. DISTRIBUIDORA DE S. M. LTDA L. D. DISTRIBUIDORA
> > 73765034000140102622574 10008AV. ANHANGUERA,
> > 02469NICOLAS BARREIRA GONZALES NICOLAS BARREIRA
> > 56599749000151336206241110 10013RUA SISA, 465
> >
> > And the I need to pass to database table like this:
> > Table Customers
> > -------------------------------------------
> > IdCustomer - 01851
> > FullName - L. D. DISTRIBUIDORA DE S. M. LTDA
> > ShortName - L. D. DISTRIBUIDORA
> > CurrNo - 73765034000140102622574
> > SpNo - 10008
> > Address - AV. ANHANGUERA
> >
> >
> > Well, I know I guess use StreamReader to read the .txt file no?
> > StreaReader x = new StreamReader("C:\\data.txt");
> > But I need some help with the logic, the loop, to do this code.
> >
> > Anyboy help me?
> >
> > Thanks in advance and sorry my English.
> >
> > Fernando Lopes
> > São Paulo - Brasil
> >
> >

>
>



Reply With Quote
  #8 (permalink)  
Unread 10-23-2010, 07:04 PM
[ F e r n a n d o L o p e s ]
 
Posts: n/a
Read from a textfile and save in database

Hello ALL,
I need to read data from a .txt file and save this data in a sql server
database table.
The .txt file format like this:
-----------------------------------------------------------
01851L. D. DISTRIBUIDORA DE S. M. LTDA L. D. DISTRIBUIDORA
73765034000140102622574 10008AV. ANHANGUERA,
02469NICOLAS BARREIRA GONZALES NICOLAS BARREIRA
56599749000151336206241110 10013RUA SISA, 465

And the I need to pass to database table like this:
Table Customers
-------------------------------------------
IdCustomer - 01851
FullName - L. D. DISTRIBUIDORA DE S. M. LTDA
ShortName - L. D. DISTRIBUIDORA
CurrNo - 73765034000140102622574
SpNo - 10008
Address - AV. ANHANGUERA


Well, I know I guess use StreamReader to read the .txt file no?
StreaReader x = new StreamReader("C:\\data.txt");
But I need some help with the logic, the loop, to do this code.

Anyboy help me?

Thanks in advance and sorry my English.

Fernando Lopes
São Paulo - Brasil


Reply With Quote
Reply

  { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Programming > ASP.NET


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 03:55 PM.


Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
© 1999-2008 mindfrost82.com v11.0


Sponsors:
eHarmony Coupon | Society 2007 | Agencia de viagens | Loans | Cash ISA



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114