[thelist] ODBC Text File Driver and ASP
Scott Dexter
sgd at ti3.com
Tue Nov 28 10:23:46 CST 2000
Here's some trimmed VB code that shows the skinny. Its early binding, so
you'd have to add the Microsoft SQLDMO Object Library to the references ....
Private oSQLServer As SQLDMO.SQLServer
Dim WithEvents oBCopyHR As SQLDMO.BulkCopy
Public Sub ImportHR(fname As String)
On Error GoTo LogError
Dim dctEmp As New Dictionary
Dim Rows As Long
Dim recString As String
Dim fields(17) As String
Dim fh_out As Integer
Dim temp_file, bcp_err_file, bcp_log_file As String
temp_file = INPUT_DIR & "hrmaster.bcp"
Set oSQLServer = New SQLServer
Set oBCopyHR = New BulkCopy
oSQLServer.EnableBcp = True
oSQLServer.Connect "DBSERVER", "userid", "password"
'Insert new data
oBCopyHR.UseExistingConnection = True
oBCopyHR.ImportRowsPerBatch = 2000
oBCopyHR.MaximumErrorsBeforeAbort = 25
bcp_log_file = LOG_DIR & "\bcp_tbhr.log"
bcp_err_file = LOG_DIR & "\bcp_tbhr.err"
oBCopyHR.LogFilePath = bcp_log_file
oBCopyHR.ErrorFilePath = bcp_err_file
oBCopyHR.DataFileType = SQLDMODataFile_CommaDelimitedChar
oBCopyHR.DataFilePath = temp_file
Rows =
oSQLServer.Databases("dbname").Tables("tbhr").ImportData(oBCopyHR)
If (Counter - Rows > 0) Then
ErrorProc "INF", Counter - Rows & " records are in error. [" &
bcp_err_file & "]", "BCPFile", CurrentSubOrFunction
Set oBCopyHR = Nothing
Set oSQLServer = Nothing
Exit Sub
LogError:
...
End Sub
More information about the thelist
mailing list