To port a Visual Basic 3.0 project that uses the old 16-bit DB-Library for Visual Basic VBSQL.VBX to a Visual Basic 4.0 project that uses the new 32-bit DB-Library for Visual Basic OLE custom control VBSQL.OCX, follow these steps:
Can't load (or register) custom control: 'C:\SQL60\BIN\VBSQL.VBX' -- Continue loading project? Custom control 'VBX.VBSQL' not found Error loading 'C:\CODE\MAIN.FRM'. A control could not be loaded due to load error. Continue?
In each case, choose the Yes or OK button.
File not found: 'C:\SQL60\DBLIB\INCLUDE\VBSQL.BAS' -- Continue loading project?
This message indicates that Visual Basic could not find a VBSQL.BAS header file in the specified location. Add the new VBSQL.BAS header file to your project.
If you do not receive this message, Visual Basic found a VBSQL.BAS header file at the location specified in your old project. Ensure that it is the new VBSQL.BAS header file. If it is the old VBSQL.BAS header file, remove the old one, and then add the new VBSQL.BAS header file to your project.
Visual Basic will place your old error handling and message handling event procedures in the list of general procedures for the form. These event procedures will be named control_Error and control_Message, where control is the name of the old VBSQL.VBX custom control, for example "VBSQL1."
Both the Error and Message event procedures have new parameters, but the existing parameters have the same names, so the old code should work unchanged.
In all of the following examples, bold text indicates the code changes you must make. For brevity, checking of return codes is not included.
For example, if your old Visual Basic project includes the following DB-Library code:
Dim LoginRec As Integer Dim SqlConn As Integer Dim Return As Integer Dim SqlCommand As String LoginRec = SqlLogin ' Fill in LoginRec SqlConn = SqlOpen(LoginRec, "gizmo") Return = SqlUse(SqlConn, "pubs") SqlCommand = "select au_fname from authors" Return = SqlCmd(SqlConn, SqlCommand) Return = SqlExec(SqlConn)
then the new code needs only the following changes:
Dim LoginRec As Long Dim SqlConn As Long Dim Return As Long Dim SqlCommand As String LoginRec = SqlLogin ' Fill in LoginRec SqlConn = SqlOpen(LoginRec, "gizmo") Return = SqlUse(SqlConn, "pubs") SqlCommand = "select au_fname from authors" Return = SqlCmd(SqlConn, SqlCommand) Return = SqlExec(SqlConn)
However, if your old Visual Basic project includes the following DB-Library code using the Integer datatype specifier (%):
LoginRec% = SqlLogin% ' Fill in LoginRec SqlConn% = SqlOpen%(LoginRec%, "gizmo") Return% = SqlUse%(SqlConn%, "pubs") SqlCommand$ = "select au_fname from authors" Return% = SqlCmd%(SqlConn%, SqlCommand$) Return% = SqlExec%(SqlConn%)
then the new code can be changed to the following, using the Long datatype specifier (&) for DB-Library functions, parameters, and return values:
LoginRec& = SqlLogin& ' Fill in LoginRec SqlConn& = SqlOpen&(LoginRec&, "gizmo") Return& = SqlUse&(SqlConn&, "pubs") SqlCommand$ = "select au_fname from authors" Return& = SqlCmd&(SqlConn&, SqlCommand$) Return& = SqlExec&(SqlConn&)
Because the datatype specifiers are not required for DB-Library function names, you can change the new code to the following:
LoginRec& = SqlLogin ' Fill in LoginRec SqlConn& = SqlOpen(LoginRec&, "gizmo") Return& = SqlUse(SqlConn&, "pubs") SqlCommand$ = "select au_fname from authors" Return& = SqlCmd(SqlConn&, SqlCommand$) Return& = SqlExec(SqlConn&)
You can also take this opportunity to change your code to use Dim to explicitly declare your variables, thus removing the Long specifier (&) from each variable.
If you forget to make a required change from Integer to Long, Visual Basic will generate the following error when you run the program:
Type-declaration character does not match declared data type
and the Visual Basic debugger will highlight the DB-Library function, parameter, or variable (for example, the SqlSetLoginTime% function or a SqlConn% variable) that is causing the error.