Problem (Inserting records into sql server 2000 using asp.net)

G

Guest

Hello,
I'm new to asp.net and ado.net so please reply considering that in mind. I'm
trying to insert some records which are in a .CSV file but the insert is
working double time. i have 744 records in .CSV file and I'm getting them in
the datareader but when I'm inserting it into table they're inserted as 1500.
So the total record count in the table is 1500.

Here is the code:

While myread.Read
myread.Read()
sqlcmd.CommandText = "Insert imported (imp) values('" &
myread.GetValue(5) & "')"
sqlcmd.Connection = sqlConn
sqlcmd.ExecuteNonQuery()
End While

Also is there no method like in Ado we use Recordset.EOF
[/QUOTE].
Thank you.
 
G

Guest

Thanks.
Here goes...........:
Code:
Dim pathname, filename As String
Dim varvalue()
pathname = Server.MapPath("import")
filename = Request.QueryString("id")

Dim ExcelConnection As New OleDbConnection
Dim ExcelCommand As New OleDbCommand
Dim ExcelAdapter As New OleDbDataAdapter
Dim ExcelDataset As New DataSet
ExcelConnection = New
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + pathname +
";Extended Properties=Text;")
ExcelConnection.Open()
ExcelCommand = New OleDbCommand("SELECT * FROM " + filename,
ExcelConnection)
Dim myread As OleDbDataReader
ExcelAdapter = New OleDbDataAdapter(ExcelCommand)
myread = ExcelCommand.ExecuteReader

'If myread.HasRows Then
Dim sqlConn As SqlConnection
sqlConn = New SqlConnection("Server=.;database=Nissan; User Id=sa;
Password=testing")
Dim sqlcmd As New SqlCommand
sqlConn.Open()

While myread.Read
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top