473,387 Members | 1,512 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,387 software developers and data experts.

Getting double records from .csv files

Hi,
I am getting some data from a .csv file through an aspx page. The total no
of records are 744 while i'm getting 1500. I couldn't really figure it out.
I'll write the code below.

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim ExcelConnection As New OleDbConnection
  3. Dim ExcelCommand As New OleDbCommand
  4. Dim ExcelAdapter As New OleDbDataAdapter
  5. Dim ExcelDataset As New DataSet
  6. ExcelConnection = New
  7. OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + pathname +
  8. ";Extended Properties=Text;")
  9. ExcelConnection.Open()
  10. ExcelCommand = New OleDbCommand("SELECT * FROM " + filename,
  11. ExcelConnection)
  12. Dim myread As OleDbDataReader
  13. ExcelAdapter = New OleDbDataAdapter(ExcelCommand)
  14. myread = ExcelCommand.ExecuteReader
  15.  
  16. 'If myread.HasRows Then
  17. Dim sqlConn As SqlConnection
  18. sqlConn = New SqlConnection("Server=.;database=Nissan; User Id=sa;
  19. Password=testing")
  20. Dim sqlcmd As New SqlCommand
  21. sqlConn.Open()
  22.  
  23. While myread.Read
  24.  
  25. 'sqlcmd.CommandText = "Insert imported (imp) values('" &
  26. myread.GetValue(5) & "')"
  27. 'sqlcmd.Connection = sqlConn
  28. 'sqlcmd.ExecuteNonQuery()
  29. Response.write (myread.getvalue(5))
  30. Response.write("<BR>")
  31. End While
  32. sqlConn.Close()
  33.  
  34.  
Can anybody please let me know what am i doing wrong over here. Also is
there any method in ado.net like ado (Recordset.EOF) because i couldn't find
any method like this as well.
Thanks in advance.

---------------------------------
Prince of Dhump
State Dhump of Himalaya

(Life is short make the full use of it)

Nov 19 '05 #1
2 1237
Hi

Where are you reading the CSV file or loading the CSV file.Is the path
name having the CSV file name... Sqldatareader.read() return true if
there are records in datareader , which is equivalent to .eof and .bof
functionalities in old ADO.

Shivprasad Koirala
C# , VB.NET , SQL SERVER , ASP.NET Interview Questions
http://www.geocities.com/dotnetinterviews/

Nov 19 '05 #2
Hello shiv,

Thank you for your reply. I solved this problem. But yes for your concern
i'll answer the questions.
Yes the path name is returing true. I'm reading the file from web server in
a directory in there called import.
I'm putting the server.mappath() function and its working because if i
remove the file or change path it is actually giving me the error that the
file couldn't be found.
I have some more questions. In ASP sometimes we put any flag variable after
recordset.movenext to do manythings. How can i implement that functionality
in .net. Furthermore is there any property like recordcount in ado.net
because i couldn't find any. Since i'm new to .net so can you please tell me
if its there which object it lies with.

Thanks

---------------------------------
Prince of Dhump
State Dhump of Himalaya

(Life is short make the full use of it)

"sh**********@yahoo.com" wrote:
Hi

Where are you reading the CSV file or loading the CSV file.Is the path
name having the CSV file name... Sqldatareader.read() return true if
there are records in datareader , which is equivalent to .eof and .bof
functionalities in old ADO.

Shivprasad Koirala
C# , VB.NET , SQL SERVER , ASP.NET Interview Questions
http://www.geocities.com/dotnetinterviews/

Nov 19 '05 #3

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

Similar topics

5
by: Gregg | last post by:
Hello all, I have been banging my head over a problem that I am having reading a comma seperated file (CSV) that can contain from 1 to 10,000 records. My code snipit is as follows: **Start...
80
by: Bibby | last post by:
Hi, I'm interested in getting started in the programming world. I've dabbled in C, C++ and VB6. Which would be the best language to focus my attention to regarding the following considerations: ...
8
by: tom | last post by:
I am new to SQL administration. >From a list of IDs that are the primary key in one table (i.e. Customer Table), I want to make changes in tables that use those IDs as a foreign key. ...
9
by: Robert Schneider | last post by:
Hi to all, I don't understand that: I try to delete a record via JDBC. But I always get the error SQL7008 with the error code 3. It seems that this has something to do with journaling, since the...
4
by: (PeteCresswell) | last post by:
I'm equi-joining two tables on a Long and a DateTime field and then comparing an amount in one with an amount the other via an Immediate If statement. Problem is that for some (not all...not...
2
by: chrisse_2 | last post by:
Hi, I am working with images which vary depending on what record you are looking at. The images are linked into my database using vba code. I would like the user to be able to double click on...
1
by: iwdu15 | last post by:
hi, how can i get the icon associated with a certain file type? thanks -- -iwdu15
1
by: Martin Pöpping | last post by:
Hello, I´ve a problem with parsing a double value from an xml file. My code looks like this: int concept_id; double rank; XmlElement root = documentXMLString.DocumentElement; XmlNodeList...
2
by: hgarg | last post by:
The onpaint() is getting called before calculating the required parameters by listBox1_SelectedIndexChanged function. I tried calling it at the end of this function. But of no use. Due to this issue...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
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...
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...

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.