Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Convert  vb6.0 to vb.net 2.0 syntax

Posted on 2009-07-01
1
Medium Priority
?
590 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 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

What do responsible coders do? They don't take detrimental shortcuts. They do take reasonable security precautions, create important automation, implement sufficient logging, fix things they break, and care about users.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Simple Linear Regression

824 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