473,402 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

First time use of a datatable

347 100+
I'm creating a datatable for the first time and I'm having some difficulties. I have the following code:

Expand|Select|Wrap|Line Numbers
  1. Protected Function Dataparse(ByVal Save As String) As String
  2.         Dim DataSet ds = new DataSet(); 
  3.         Dim Datatable dt = new Datatable();
  4.          System.Data.Odbc.OdbcConnection conn;   
  5.             System.Data.Odbc.OdbcDataAdapter da;   
  6.             string connString;   
  7.             string importFolder = @"\\MSBWEB3\wwwroot\Webfile1\Reminders\Doug_Ancil\";   
  8.             string fileName = "doug.csv";   
  9.             connString = @"Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" + importFolder + ";";   
  10.             conn = new System.Data.Odbc.OdbcConnection(connString);   
  11.             da = new System.Data.Odbc.OdbcDataAdapter("select * from [" + fileName + "]", conn);    
  12.             da.Fill(ds,"Sample"); 
  13.  
  14.     End Function
  15.  
What I'm trying to do is as follows:

I have the following data that basically I only need a few bits of information from:

Resource:Wills MD, Robert P; Ward LPC LSOTP, Tracy K; Wages MD, John; von Leonrod FNP C, Sara; Teague PA C, Donna; Prewitt Buchanan MD, Laura K; NO - Medical Assistant; NO - C2 Pickup; Morgan FNP C, Nancy; Minot APRN, S. Reid; Medical Assistants; Martin LCSW, Margaret; Lepore MA LPC, Bruno; Iseminger PA C, Amy C; Intern; Horwath PA C, Jessica; Hart PA C, Mary Jo; Haden LCSW, Marion M; Group Services; Frank MD, Brannon R; DuBois MD, Craig; Chandler LCSW, Michele; C2 Pickup - Main Office; Brothers LCSW, Gary; Bates FNP C, Gina; Anderson MD, Christine
Facility:Austin Pain Associates - North Office; Austin Pain Associates - Kyle; Austin Pain Associates - Georgetown; Austin Pain Associates - Cedar Park; Austin Pain Associates
Type:(all)
From Date: 07/12/2010 - To Date 07/12/2010
Sort by:Time
Include Referring source/physician:No
Footer:Default
Criteria:None
","Appointments","Brothers LCSW, Gary","Austin Pain Associates","Monday, July 12, 2010","Time","Patient Name","Patient ID","Appt. Type","Ref. Source/ Physician","Phone","Type","DOB ","Brothers LCSW, Gary","Austin Pain Associates","7/12/2010 12:00:00AM","Time","Patient Name","Patient ID","Appt. Type","Phone","Type","DOB "," 7:30 AM","Muniz Jr, Reynaldo A","27380","SO - Ind Psych Therapy - 45","","(512) xxx-7023","Mobile","03/25/1965"," 7:30 AM","Muniz Jr, Reynaldo A","27380","SO - Ind Psych Therapy - 45","(512) xxx-7023","Mobile","03/25/1965","Truong, Kimphuong P","(512) xxx-5472","Financial Class:","Medicare","Status:","Auth Complete","","","Age:","45 yrs","Notes:","counseling - conniesiver

The only things I need from this are:

Patients Name

Drs Name

Patients Phone Number

Appt Time

Appt Date

and the rest of the information I can discard. A customer uploads this as a .csv file (even though it really isn't as you can see) and I'd like to parse the needed information and post that to my SQL database and discard the rest. I think I can do this with a dataset but I've never built that before. The fields from the customer will always be the same and the fields I will need will always be the same.

Also, the date time has to be in the format of yyyy/mm/dd:hhmm and the phone number always has to have 512 as a prefix.

This is my first time creating a datatable and I've read how to create them but I'm having some problems. Any help would be appreciated.

Thank you,

Doug
Jul 15 '10 #1
1 1698
Hey Doug,

Like we talked about - you cannot use ADO.NET to work with that file: the file is not tabular. It is not in a format that can yeild columns and rows. Just because there are a bunch of commas in there doesn't mean that it is a proper CSV file. To understand this, try to open that file in Excel. You will not get a structure that is similiar to a database table. When you previously asked "can I use a DataTable", I thought you meant you would define the DataTable, parse the file by hand, assign the parsed values to DataColumns in DataRows, add the DataRows to the DataTable, add the DataTable to a Dataset and update the Dataset with the appropriate data commands. It is a bit much, but it is doable. I would just parse the file row by row and commit the data with a DataCommand that is defined with a SPROC.

In short, there is no single step from that source file to any object that represents a database or data table. You need to code an in-between routine to transform the source.
Jul 15 '10 #2

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

Similar topics

2
by: Slide-O-Mix | last post by:
I am using the Process class to run an external application from my application. The first time I call the .Start() method it takes several seconds for the process to actually start. Subsequent...
1
by: Steve Bishop | last post by:
I have an application that uses data access that runs slow the first time. My first page reads data from an ODBC source and the second page hits a MSDE database. After each page opens the first...
1
by: Shourie | last post by:
I've noticed that none of the child controls events are firing for the first time from the dynamic user control. Here is the event cycle. 1) MainPage_load 2) User control1_Load user clicks a...
1
by: BK Kim | last post by:
Hello. I have made my aspx websites and I realized that my application is running slow at the first time but next time, it is very fast. Is it because the codes are compiled at the first time?...
11
by: Jason | last post by:
Hi I have a "problem" i have got a ASP.NET application. in this application i have included logging. in the logging i have logged how many seconds it takes for this application to fully load....
16
by: TB | last post by:
Hi all: If you think that the following comments are absolute amateurish, then please bear with me, or simply skip this thread. A couple of months back I made the decision to initiate a...
3
by: goldie11 | last post by:
Hi, This is the first time I use a gridview. I have two big problems: 1) I need to assign the columns of the gridview from the code (the cs file )- because the assignment of the columns...
3
by: Torben Laursen | last post by:
I have a COM shared add-in written in C# that I use in Excel. One of the thinks that the user can do is to open some winforms. The problem that I have is that the first time the user opens a...
3
AnuSumesh
by: AnuSumesh | last post by:
Hi, I have created two web pages say first.asp and second.asp. first.asp has a link of second.asp and username is embedded in url of second.asp.(second.asp?username=dvhsdghsdg) Second.asp has...
7
by: ArizonaJohn | last post by:
Hello, On my site, a user enters a value into a form, and if that value is not in my database, the code below is meant to give the user the message "The topic "value" has not been added. Add the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
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...

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.