hi everyone!
i'm rather new to
vb.NET. i'm trying to migrate from vb6 to
vb.NET. i've got visual studio 2003 installed. my problem is this:
in vb6 i use this code for a method in a class (clsVehicles):
------------------------------------------------------------
Option Explicit
Dim conDB As ADODB.Connection
Dim strSQL As String
Private Sub Class_Initialize()
Set conDB = New ADODB.Connection
conDB.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source =D:\LUECO\MPCS\MotorPool.mdb"
End Sub
Private Sub Class_Terminate()
Set conDB = Nothing
End Sub
Public Function Add_Vehicle(ByVal strUnitNo As String, _
ByVal strVtype As String, _
ByVal strPlateNo As String, _
ByVal strRegCert As String, _
ByVal dtExpiry As Date, _
ByVal strDriver1 As String, _
ByVal strDriver2 As String) As Boolean
Dim rsVehicle As New ADODB.Recordset
On Error GoTo ErrHandler
conDB.Open
conDB.CursorLocation = adUseServer
strSQL = "SELECT * FROM vehicles WHERE 1=2"
rsVehicle.Open strSQL, conDB, adOpenKeyset, adLockOptimistic
conDB.BeginTrans
With rsVehicle
.AddNew
.Fields("Unit_No") = strUnitNo
.Fields("Vehicle_Type") = strVtype
.Fields("Plate_No") = strPlateNo
.Fields("LTO_Reg_No") = strRegCert
.Fields("Expiry_Date") = dtExpiry
.Fields("Driver_1") = strDriver1
.Fields("Driver_2") = strDriver2
.Update
End With
conDB.CommitTrans
Add_Vehicle = True
conDB.Close
Exit Function
ErrHandler:
Debug.Print "Error : " & Err.Number & " - " & Err.Description
conDB.RollbackTrans
conDB.Close
Add_Vehicle = False
End Function
-------------------------------
i would like to convert the code to
vb.NET (2003 version)
would anyone show me how?
thanks a lot
jorge