473,513 Members | 2,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

reg: Simple, Help me out

Hi All:

I got a .txt file with five columns, it's named as in the first line with
double quotes of each column. And from the second line onwards, the real
data. So i would like keep the these data in their corresponding columns in
the sql database. I created a table with these 5 columns in the database,
now i want these data to be dumped into database. So initially iam trying to
read line by line, and spliting using "" as a delimiter. But am not able to
do it. Iam sending my code along with this data, pls help me out.

"Activity Name","Start Date","Finish Date","Resources Assigned","Notes per
Bar"

"HLD","7/2/03","7/30/03",,
"Interal Design","7/2/03","7/3/03","RamaKrishna, Kittu","hai"
"Interal Design of ATP","7/8/03","7/9/03","RamaKrishna, Richard",
"Sign-Off","7/9/03","7/9/03","RamaKrishna",

Dim objReader As New StreamReader("c:\TestData.txt")

'Inserting ProjectData into SQL Database

Dim cnDBConnection As New SqlConnection("Data Source=goutham;
Database=pubs;User ID=sa;Pwd=sa")

cnDBConnection.Open()

Dim sqlInsertCommand As New SqlCommand()

While objReader.Peek > -1

str = objReader.ReadLine

'Response.Write(str & "<br>")

strSplit = Split(str, """")

For i = 1 To UBound(strSplit) - 1

'Response.Write(strSplit(i) & "<br>")

arrStrColumnNamesAfterNew = Split(strSplit(i), ",")

Next

sqlInsertCommand.CommandText = "Insert into ProjectData([Activity
Name],[Start Date],[Finish Date],[Resources Assigned],[Notes Per Bar])
values('" & arrStrColumnNamesAfterNew(0) & "', '" &
arrStrColumnNamesAfterNew(1) & "' , '" & arrStrColumnNamesAfterNew(2) & "' ,
'" & arrStrColumnNamesAfterNew(3) & "',, '" & arrStrColumnNamesAfterNew(4) &
"')"

sqlInsertCommand.Connection = cnDBConnection

sqlInsertCommand.ExecuteNonQuery()

Pls help me out.

Waiting for ur reply.

Best regards,

RK



Jul 19 '05 #1
1 1474
Hi:
Tx for ur suggestions. But can it can be done. U got any code for that. Pls
let me know. Or is there any easy process, that if we give inout as .txt,
file automatically it'll dump into the database?

Waiting for ur reply.
Best regards,
RK

"David Waz..." <dl*@pickpro.com> wrote in message
news:PX*********************@newssvr11.news.prodig y.com...
your data has commas within the data, and that is making the task more
difficult.

you need to accommodate the commas in the data, and possible quotation marks in the data.
check out regular expressions, or try to read the data field at a time
instead of line at a time.

"Rama krishna" <rm*********@vertexcs.com> wrote in message
news:uP**************@TK2MSFTNGP12.phx.gbl...
Hi All:

I got a .txt file with five columns, it's named as in the first line with double quotes of each column. And from the second line onwards, the real
data. So i would like keep the these data in their corresponding columns in
the sql database. I created a table with these 5 columns in the database, now i want these data to be dumped into database. So initially iam trying to
read line by line, and spliting using "" as a delimiter. But am not able to
do it. Iam sending my code along with this data, pls help me out.

"Activity Name","Start Date","Finish Date","Resources Assigned","Notes

per Bar"

"HLD","7/2/03","7/30/03",,
"Interal Design","7/2/03","7/3/03","RamaKrishna, Kittu","hai"
"Interal Design of ATP","7/8/03","7/9/03","RamaKrishna, Richard",
"Sign-Off","7/9/03","7/9/03","RamaKrishna",

Dim objReader As New StreamReader("c:\TestData.txt")

'Inserting ProjectData into SQL Database

Dim cnDBConnection As New SqlConnection("Data Source=goutham;
Database=pubs;User ID=sa;Pwd=sa")

cnDBConnection.Open()

Dim sqlInsertCommand As New SqlCommand()

While objReader.Peek > -1

str = objReader.ReadLine

'Response.Write(str & "<br>")

strSplit = Split(str, """")

For i = 1 To UBound(strSplit) - 1

'Response.Write(strSplit(i) & "<br>")

arrStrColumnNamesAfterNew = Split(strSplit(i), ",")

Next

sqlInsertCommand.CommandText = "Insert into ProjectData([Activity
Name],[Start Date],[Finish Date],[Resources Assigned],[Notes Per Bar])
values('" & arrStrColumnNamesAfterNew(0) & "', '" &
arrStrColumnNamesAfterNew(1) & "' , '" & arrStrColumnNamesAfterNew(2) &

"' ,
'" & arrStrColumnNamesAfterNew(3) & "',, '" &
arrStrColumnNamesAfterNew(4) &
"')"

sqlInsertCommand.Connection = cnDBConnection

sqlInsertCommand.ExecuteNonQuery()

Pls help me out.

Waiting for ur reply.

Best regards,

RK



Jul 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
8746
by: Mark J. McGinty | last post by:
Greets, One site I've written allows the user to install an IE extension menu (not malware at all) by downloading/merging a short .REG file. Worked like a peach on Win2K Server, now that I...
5
1758
by: Henok Girma | last post by:
Hello Gurus, I wanted to have a very simple, strict regular expression validator for a phone field. the only valid format is (XXX) XXX-XXXX where X is a digit I have the following but it always...
1
1956
by: worzel | last post by:
Hi All, I am looking for a reg ex that will match email addresses withing <a href=mailto blah > links. Actually, I already crafted my own, but with a slight problem: <a...
1
2626
by: dixie | last post by:
I have a .reg file that I need to run across a network. Currently, we run it for each logon on the network manually, which is not really working well as there are over a hundred users and they...
7
18241
by: DraguVaso | last post by:
Hi, Does anybody knows how to run a *.reg-file silently on a computer? I need this to do automatic updates of my application without user-interaction. So I don't want the user to be asked a...
1
4917
by: Anurag | last post by:
Hi, I have 2 related questions. DB2 UDB ESE v8.x (8.1 till 8.2 FP2 - all fixpaks included) on AIX 5.4.x _____________________________________________________________________________ (QUESTION 1)...
11
1215
by: don | last post by:
I have a string from a clearcase cleartool ls command. /main/parallel_branch_1/release_branch_1.0/dbg_for_python/CHECKEDOUT from /main/parallel_branch_1/release_branch_1.0/4 I want to write a...
2
1120
by: Phillip Vong | last post by:
I'm looking for a simple Reg Expression to validate a textbox where the text must in in .doc or .pdf or .tif. Thanks in advance. Phil
1
1249
by: black_13 | last post by:
are there any python modules for manipulation of .reg files producted by the win32 prog "reg". thanks. black_13
6
1682
by: LeWalrus | last post by:
Hi, I've written a reg exp for capturing a group of numbers from text files in the following format: -1.4326 s < 0.6758 s < 1.4334 s Any of the numbers can be positive or negative and the units...
0
7384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7099
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5685
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4746
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3233
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1594
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
799
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.