VYX Level: Professor

 Registered: 16-12-2005 Posts: 78
|
VB6 to C# convert coding
Guys..
I have this kind of coding techniques in VB6 and i want this to convert into C# and VB.net.
I created a module for connectionn something like this
Public Function CONNECT(ByRef cn As ADODB.Connection, ByRef rs As ADODB.Recordset, ByRef sql As Variant) As Boolean
On Error GoTo errs
cn.Open vConnectionString'=sql connectionstring
With rs
.CursorLocation = adUseClient
.Open sql, cn, adOpenKeyset, adLockOptimistic
End With
CONNECT = True
Exit Function
'End If
Exit Function
End Function
Public Sub disconnect(ByRef cn As ADODB.Connection, ByRef rs As ADODB.Recordset)
Set cn = Nothing
Set rs = Nothing
End Sub
then at form if i am going to populate a list view
i created like this
Public Sub ListAllORCollected()
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim vsql As String
LVIEW.ListItems.Clear
vsql = "select idno,trdate,fullname,totalreceived from tblINFO"
With LVIEW
'.Visible = False
.Checkboxes = False
.FullRowSelect = True
Set .SmallIcons = ImageList1
CONNECT cn, rs, vsql
With rs
If .RecordCount > 0 Then
.MoveFirst
Do While Not .EOF
Set X = LVIEW.ListItems.Add(, , UCase(!idno)) ' On Error Resume Next
X.SubItems(1) = UCase(!TRDate)
X.SubItems(2) = UCase(Trim(!FullName))
X.SubItems(3) = FormatNumber(!totalreceived, 2, vbTrue) ''amount
.MoveNext
Loop
End If
End With
End With
disconnect cn, rs
End Sub
Could anyone help me out how to workout on this..
Thanks in advance.. All your help suggestions and idea about this, really appreciated,
Thank you
|