Bulk Insert type mismatch

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I'm trying to load a comma delimeter file into an sql database. I've tried
the query analyzer and now I'm using VB.NET. I get the same error when doing
both, "type mismatch". I know where the issue lies. The actually columns in
the table are more than the number of columns in the import file. When
uploading I get the error "type mismatch on the last column of upload file.
The code is below.

In addition, I would like to use the openfiledialog box to insert file into
the BULK INSERT statement. Any ideas on how to do that would be great as
well.

Thanks,

Dim cnn As New SqlConnection
Dim myCommand As SqlClient.SqlCommand
Dim strSQL As String
cnn = New SqlConnection("Initial Catalog=FULTON;" & _
"Data Source=CUSPAPHINSI0113\MYINSTANCE;Integrated
Security=SSPI;")

cnn.Open()
strSQL = "BULK INSERT Fulton.dbo.[2005] FROM
'C:\INTELIS\INBOX\SQLTEST.DAT' WITH ( FIELDTERMINATOR = ',', ROWTERMINATOR =
'\n' )"

myCommand = New SqlClient.SqlCommand(strSQL, cnn)
myCommand.ExecuteNonQuery()

cnn.Close()
cnn = Nothing
 
This may help as well. Here's a sample from the file. The first line
represent the table I would like to insert into. The second and third lines
are the actual columns that will be updated providing the first two columns
(Intelis and 51110) of file exist. Error above happens when the "6789.00000"
column is read.

ACTUAL
1
2
Intelis,51100,12345.00000,6789.00000
 
Back
Top