Solved

Convert  vb6.0 to vb.net 2.0 syntax

Posted on 2009-07-01
1
583 Views
Last Modified: 2012-05-07
Hi,
Can anybody suggest on converting the function from vb6.0 to vb.net 2.0

Cheers
Public Function GetCodes(formid As String) As Boolean
Dim SQL As String
Dim RsCodes As Recordset
Dim rsCodesTable As Recordset
Dim clause As String
'
'identify if the formid has any codes associated with it.
'
SQL = "Select tag,ctrltype from Controls where " & ctUcase & "(formid) = " & UCase(GetSQLValue(formid, ctText)) & _
" AND " & ctUcase & "(Ctrltype) <> " & GetSQLValue("LABEL", ctText)
 
Set RsCodes = OpenRs(SQL, SysDB)
If RsCodes.EOF Or RsCodes.BOF Then
    'no controls associated with this form
Else
    'make a in statement of all fieldnames
    Do Until RsCodes.EOF
        clause = clause & UCase(GetSQLValue(RsCodes!Tag, ctText)) & ", "
        RsCodes.MoveNext
    Loop
End If
If clause <> Empty Then
    clause = UCase(" IN (" & Left(clause, Len(clause) - 2) & ")")
End If
RsCodes.Close
 
If clause <> "" Then
    SQL = "Select Count(*) as Tot FROM Codes WHERE " & ctUcase & "(fieldname) " & clause
    Set rsCodesTable = OpenRs(SQL, MemDB)
    If rsCodesTable!Tot = 0 Then
        GetCodes = False
    Else
        GetCodes = True
    End If
    rsCodesTable.Close
    If GetCodes = True Then
        'if codes exist then exit sub
        Exit Function
    End If
End If
 
 
'
'Secondly - find out if the formid have any links to the codes table
'
SQL = "Select Count(*) as Tot from Controls where formid = " & GetSQLValue(formid, ctText) & " and linktable = 'CODES'"
Set RsCodes = OpenRs(SQL, SysDB)
If RsCodes!Tot = 0 Then
    GetCodes = False
Else
    GetCodes = True
End If
RsCodes.Close
Set RsCodes = Nothing
Set rsCodesTable = Nothing
 
End Function

Open in new window

0
Comment
Question by:RIAS
1 Comment
 
LVL 15

Accepted Solution

by:
mohan_sekar earned 500 total points
ID: 24754469
Use SQLDataReader for RecordSet and SQLConnection for Connection.

For Do until RsCodes.EOF, use

While reader.Read()
...your stuff
End While

Reset of them should be straightforward.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question