Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using VBSQL.OCX to control SQL Server

Status
Not open for further replies.

dg043

Programmer
Apr 22, 2002
52
GB
I am writing a program to batch copy data from an operating system file into a table in SQL Server 6.5. I have discovered an ActiveX control in the SQL Server programmer's toolkit called VBSQL.OCX which provides several methods to allow me to do this. Here is my code so far:

[tt]Dim login_id As Long, connection_id As Long
Dim rows As Long

login_id = SqlLogin
If SqlBCPSetL(login_id, True) = 0 Then
error = "Failed to enable BCP on the connection"
End If
If SqlSetLUser(login_id, "sa") = 0 Then
error = "Failed to set SQL user"
End If
If SqlSetLPwd(login_id, "sPac31999") = 0 Then
error = "Failed to set SQL password"
End If
connection_id = SqlOpen(login_id, "BISUAT")
If connection_id = 0 Then
error = "Login Failed"
Else
If SqlBCPInit(connection_id, "Shorthaul.dbo.System_Inputs", App.Path & "\inputs.dat", App.Path & "\Errors.log", DBIN) = 0 Then
error = "Failed to initialise BCP operation"
End If
If SqlBCPExec(connection_id, rows) = 0 Then
error = "Failed to complete BCP operation"
Else
MsgBox rows & " rows imported"
End If
SqlExit
SqlWinExit
End If[/tt]

When executed, the application runs until it gets to the [tt]SQLBCPExec[/tt] line. When it tries to run this, it forces the Visual Basic IDE to crash with a message saying that "Visual Basic has encountered a problem and needs to close". Has anybody come across this problem or anything like it?


Dan Griffiths
Software Analyst
National Grid Transco (NGT)
 
I'm afraid so. At least for the next few months. Is that the problem then?

Dan Griffiths
Software Analyst
National Grid Transco (NGT)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top