|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
Usually that error occurs when you are missing an "Imports". Are you sure you have the correct Imports line?
|
|
#3
|
||||
|
||||
|
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
|
![]() |
| Viewing: ASP Free Forums > Programming > .NET Development > ASP.Net/VB.Net - Csvdatareader |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|