473,667 Members | 2,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

i am trying to read a 2 way delimited txt file into sqlserver in C# 2008.

9 New Member
i am trying to read a 2 way delimited txt file into sqlserver in VS2008 using C# and SQL server2005. the individual entries of the file are delimited by "~" and the data within the entries are separated using "$". and i need to read the entries as rows in the database and the data within each entry i.e. delimited by $ as columns or fields in the database.

since i am new to .net, i am not able to do the 2 way delimiting and read all the rows into the database.

here is a pattern of the data we are dealing with...

*************** *************** *************** ***********
12:02:16 AM$206.79.184.1 23$eejyaqmgcm0c dj45apdeeu55$Av ailability$Gene ral network error.~
12:02 AM$170.35.208.2 2$bo1lbm455s1di 245asulqrjc$onl ine_booking.asp x$Object reference not set to an instance of an object.~

*************** *************** *************** ***********

as u can see, ~ separates two different entries...i.e to be entered as rows in the database. and $ separates the data within each entry...i.e the columns inside each row in the database.

i would be very thankful if u could help me in this matter as soon as possible.
Jul 16 '10 #1
4 1389
GaryTexmo
1,501 Recognized Expert Top Contributor
Have a look at the String.Split method.

You can use it to tokenize your source string by ~. Then use it again on each token returned by the first split to further tokenize those lines by #.

Also, note that in the second token (by ~) you've got a space in one of the items.. "online_b oooking.aspx" instead of "online_booking .aspx". Typo? Maybe check your source file.

Try playing with String.Split and let us know if you have any questions! :)
Jul 16 '10 #2
indona
9 New Member
thanks a lot for the reply. i have just done the reading of the file with the split function by displaying the lines onto cmd. thanks a lot for the help.
but i am still not sure about the part of reading the data into the database. can you plz help me with some sample code for this.
Jul 16 '10 #3
GaryTexmo
1,501 Recognized Expert Top Contributor
Sorry, I'm not overly experienced with working with databases, nor do I have your setup. If it's a DataSet you're putting it into, and each delimited item represents a column, you should be able to tell the column number by the index in the split array.

I dunno if that helps or not...
Jul 16 '10 #4
indona
9 New Member
okay.... i will try with d index part u just mentioned..
anyway thanks a lot..
Jul 16 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
4719
by: jrlen balane | last post by:
how would i read a tab delimited file? at the same time put what i read in an array, say for example that i know that the file is an array with column= 5 and row=unknown.
1
7936
by: Rob | last post by:
Hi, Sorry if this has been asked before(I searched, but didn't see anything). I need to read a tab delimted file into an array with ASP. Should be easy enough, I know it is in Perl and PHP. Can someone show me how that's done or post a link to an example. This is what I'm trying to do in perl:
3
21823
by: TF | last post by:
Hi, I have to access data from a comma delimited file in .net windows application (VB.net or C#). I am using Microsoft.Jet.OLEDB.4.0 provider for this purpose. Now the problem is when i extract data from a file with extension csv or txt it works fine but as soon as i change the extension, like 'log' or 'abc' it gives following error in 'Fill' function of 'OleDbDataAdapter': Cannot update. Database or object is read-only
3
2785
by: monte | last post by:
Hello, I need to parse a tilde delimited file and output it to a tabbed delimited file. Example file example.txt data1~data2~data3~data4 data5~data6~data7~data8 I need to extract data2, data4, data6 and data8 from the above file and output it to a file delimited by tabs: data2 data4 data6 data8
6
1787
by: Skc | last post by:
I am trying to import a file using a custom VB.net procedure, but the problem is it works on a file with pure comma separation and not inverted commas and commas, i.e. it works for AAA,BBB,CCC,DDD but not for "AAA","BBB","CCC","DDD". Here is an extract from the code which needs to be modified for the """: Sub LoadTextFile(ByVal strFilePath As String) Dim oDS As New DataSet() Dim strFields As String Dim oTable As New DataTable()
4
13287
by: Hilary Cotter | last post by:
Thanks for all the help you gave me yesterday. here is another question. I have a comma delimited file called redirect.txt which looks like this test, /test.htm test 123,/test123.htm
1
2580
by: j7.henry | last post by:
I am trying to pull specific data that is in a comma delimited file into a web page. So if my comma delimited file looks like: Name,Address,Zip Fred,123 Elm,66666 Mike,23 Jump,11111 I would like to be able to read this data and put each row into a variable? so I could display the values in a web page where I want.
1
7805
jwwicks
by: jwwicks | last post by:
Hello All, This is a student assignment. So I don't want the complete answer just a hint or maybe a bumb on the head cause I'm doing it the wrong way. Assume I haven't done anything braindead like not include a header etc... I can post the whole code if you like/need it but I'm trying to spare the forum :) Got a product structure... struct product { string id; string description; int quantity;
11
1899
by: kimmelsd33 | last post by:
I would like some expert advice. I am writing in VB6. I am opening a tab delimited file, deleting the first 50 lines, and rewriting the file to a temp file. The temp file has about 20 columns with x number of lines. What I am trying to do, is open the tab delimited file, and read each column into a named variable, ex. depth<column1>mpf<column2>tg<column3>,etc. I have written a function to take the variable from column2(mpf) & create another...
7
3330
by: kimmelsd33 | last post by:
I am using VB6. I want to read a tab delimited file, and assign each column value into a variable. If the variable is "-999.25", I want to make it a "0". I then want to reassemble the values, and write them to a temp text file. Starting with line 64, I have about 28 columns and x number of rows. Ex: 1000<tab>23.3<tab>-999.25<tab> etc. The value of -999.25 can be in any column. I need to replace it before it is stored in the variable. I need to...
0
8458
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8366
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,...
0
8790
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7391
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, 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...
0
5677
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();...
0
4202
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...
1
2779
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 we have to send another system
2
2017
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1779
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 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...

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.