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","Resource s Assigned","Note s per
Bar"
"HLD","7/2/03","7/30/03",,
"Interal Design","7/2/03","7/3/03","RamaKrishn a, Kittu","hai"
"Interal Design of ATP","7/8/03","7/9/03","RamaKrishn a, Richard",
"Sign-Off","7/9/03","7/9/03","RamaKrishn a",
Dim objReader As New StreamReader("c :\TestData.txt" )
'Inserting ProjectData into SQL Database
Dim cnDBConnection As New SqlConnection(" Data Source=goutham;
Database=pubs;U ser ID=sa;Pwd=sa")
cnDBConnection. Open()
Dim sqlInsertComman d As New SqlCommand()
While objReader.Peek > -1
str = objReader.ReadL ine
'Response.Write (str & "<br>")
strSplit = Split(str, """")
For i = 1 To UBound(strSplit ) - 1
'Response.Write (strSplit(i) & "<br>")
arrStrColumnNam esAfterNew = Split(strSplit( i), ",")
Next
sqlInsertComman d.CommandText = "Insert into ProjectData([Activity
Name],[Start Date],[Finish Date],[Resources Assigned],[Notes Per Bar])
values('" & arrStrColumnNam esAfterNew(0) & "', '" &
arrStrColumnNam esAfterNew(1) & "' , '" & arrStrColumnNam esAfterNew(2) & "' ,
'" & arrStrColumnNam esAfterNew(3) & "',, '" & arrStrColumnNam esAfterNew(4) &
"')"
sqlInsertComman d.Connection = cnDBConnection
sqlInsertComman d.ExecuteNonQue ry()
Pls help me out.
Waiting for ur reply.
Best regards,
RK 1 1481
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.co m> wrote in message
news:PX******** *************@n ewssvr11.news.p rodigy.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*********@ve rtexcs.com> wrote in message news:uP******** ******@TK2MSFTN GP12.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","Resource s Assigned","Note s
per Bar"
"HLD","7/2/03","7/30/03",, "Interal Design","7/2/03","7/3/03","RamaKrishn a, Kittu","hai" "Interal Design of ATP","7/8/03","7/9/03","RamaKrishn a, Richard", "Sign-Off","7/9/03","7/9/03","RamaKrishn a", Dim objReader As New StreamReader("c :\TestData.txt" ) 'Inserting ProjectData into SQL Database
Dim cnDBConnection As New SqlConnection(" Data Source=goutham; Database=pubs;U ser ID=sa;Pwd=sa")
cnDBConnection. Open()
Dim sqlInsertComman d As New SqlCommand()
While objReader.Peek > -1
str = objReader.ReadL ine
'Response.Write (str & "<br>")
strSplit = Split(str, """")
For i = 1 To UBound(strSplit ) - 1
'Response.Write (strSplit(i) & "<br>") arrStrColumnNam esAfterNew = Split(strSplit( i), ",") Next
sqlInsertComman d.CommandText = "Insert into ProjectData([Activity Name],[Start Date],[Finish Date],[Resources Assigned],[Notes Per Bar]) values('" & arrStrColumnNam esAfterNew(0) & "', '" & arrStrColumnNam esAfterNew(1) & "' , '" & arrStrColumnNam esAfterNew(2) &
"' , '" & arrStrColumnNam esAfterNew(3) & "',, '" &
arrStrColumnNam esAfterNew(4) & "')"
sqlInsertComman d.Connection = cnDBConnection
sqlInsertComman d.ExecuteNonQue ry() Pls help me out.
Waiting for ur reply.
Best regards,
RK
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 upgraded to Server 2003, it returns a 404
file not found error. I'm positive the file is there/spelled right. I
changed it to .txt and it displays the text in the user's browser.
So there's little question that this is some "security" addition, to...
|
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 evaluates to false
var reg = new RegExp("^\(\d{3}\) \d{3}-\d{4}$");
alert(reg.test("(123) 221-9244"));
Any help is greatly appreciated..
|
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 href="mailto:fred@blah.com"> emal me</a> woud be matched as expected, but
so will:
|
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 don't necessarily all use their
own machines all the time. How does the system administrator run a .reg
file for all users on the network. If this is off topic, could you please
direct me to an area where I might get a response. The reason for...
|
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 confirmation before writing
everything to the registry, and I don't want a succes-or-error-message at
the end.
Any help would be really appreciated!
| |
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)
Output of "db2ilist" does not list all the instances on my AIX box.
DB2 functions normally - I do not get any unexpected errors.
Any ideas what configuration has been missed out?...
|
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 regex that gives me the branch the file was
checkedout on ,in this case - 'dbg_for_python'
Also if there is a better way than using regex, please let me know.
|
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
|
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
|
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 (s) can change or even be absent. What I wanted was the three numbers (signs included)! Here was the reg exp I used to capture:
$line =~ m!(\d+\.\d+)\s+.*?<\s+(\d+\.\d+)\s+(.*?)<\s+(\d+\.\d+)!
The problem is that this must be used hundreds of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| | |