![]() |
|
|
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. |
|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
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 > > |
|
|||
|
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 > > > > > > |
|
|||
|
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 > > > > > > > > > > > > |
|
|||
|
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 > > |
|
|||
|
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 > > > > > > |
|
|||
|
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 > > > > > > > > > > > > |
|
|||
|
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 > > > > > > |
|
|||
|
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 |
![]() |
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|