.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today!
  #1  
Old May 12th, 2008, 03:45 PM
akpaga akpaga is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 27 akpaga User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 23 m 4 sec
Reputation Power: 0
ASP.Net/VB.Net - Csvdatareader

Hi shows an error --type "csvdatareader " not defined
when i complie the below code.
What is the problem?

Thanks


Imports System.Data
Imports System.Data.SqlDbType
Imports System.Data.SqlClient
Imports System.Web.Configuration
Imports System.Collections.Generic
Imports System.Text



Partial Class _Default
Inherits System.Web.UI.Page


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load




End Sub


Protected Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

Using csvData As CsvDataReader = New CsvDataReader(FileUpload.PostedFile.InputStream, Encoding.Default)
csvData.Settings.HasHeaders = True

csvData.Columns.Add("varchar")
csvData.Columns.Add("varchar")

Using bulkCopy = New SqlBulkCopy("Data Source=.;Initial Catalog=Test;User ID=sa;Password=")
bulkCopy.DestinationTableName = "Tempmembers"


bulkCopy.ColumnMappings.Add("member_id", "member_id")
bulkCopy.ColumnMappings.Add("member_name", "member_name")

bulkCopy.WriteToServer(csvData)
End Using ' dispose of CsvDataReader object
End Using ' dispose of CsvDataReader object

End Sub


Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
'Declare Variables - Edit these based on your particular situation

End Sub
End Class

Reply With Quote
  #2  
Old May 13th, 2008, 06:07 PM
Michaelwh Michaelwh is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: May 2008
Posts: 4 Michaelwh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 49 m 34 sec
Reputation Power: 0
Usually that error occurs when you are missing an "Imports". Are you sure you have the correct Imports line?

Reply With Quote
  #3  
Old May 14th, 2008, 04:01 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,738 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 1 h 31 m 55 sec
Reputation Power: 443
Not sure what you are doing with a "Using" statement, as that pertains to C# not VB.NET.

Try something like this...
Code:
Imports System.Data
Imports System.Data.SqlDbType
Imports System.Data.SqlClient
Imports System.Web.Configuration
Imports System.Collections.Generic
Imports System.Text



Partial Class _Default
Inherits System.Web.UI.Page

   Private csvData As CsvDataReader 

   Protected Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
      csvData = New CsvDataReader(FileUpload.PostedFile.InputStream, Encoding.Default)
      rest of code
   End Sub
End Class

Reply With Quote
Reply

Viewing: ASP Free ForumsProgramming.NET Development > ASP.Net/VB.Net - Csvdatareader


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway