Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Problem (Inserting records into sql server 2000 using asp.net)

Reply
Thread Tools

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

 
 
=?Utf-8?B?UCBvZiBEaHVtcA==?=
Guest
Posts: n/a
 
      08-18-2005
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
.
Thank you.


 
Reply With Quote
 
 
 
 
Clint Hill
Guest
Posts: n/a
 
      08-18-2005
It may help to see how you are populating the myread DataReader?

Clint Hill
H3O Software
http://www.h3osoftware.com


P of Dhump wrote:
> 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
>
.
> Thank you.
>
>

 
Reply With Quote
 
 
 
 
=?Utf-8?B?UCBvZiBEaHVtcA==?=
Guest
Posts: n/a
 
      08-18-2005
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
---------------------------------
Prince of Dhump
State Dhump of Himalaya

(Life is short make the full use of it)

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MS Sync Framework & SQL Server 2000 & 250k+ records Granby ASP .Net Web Services 0 12-09-2008 11:06 AM
Creating a page for inserting new records into a SQL Server 2000 DB newt039@gmail.com ASP .Net 0 01-26-2007 09:33 PM
Do the Self-Paced Training Kits: Microsoft SQL Server 2000 include Eval copy of SQL Server? Brian Whiting Microsoft Certification 2 12-29-2005 04:24 AM
sql server express vs sql server 2000 code Daves ASP .Net 1 06-13-2005 12:24 PM
Microsoft Exchange 2000 Server OR Microsoft SQL Server 2000 Sam MCSE 11 06-03-2005 08:29 PM



Advertisments