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
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