Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Help migrating vb6 code to VB.net

Posted on 2008-06-13
2
Medium Priority
?
1,678 Views
Last Modified: 2013-12-20
I'm migrating a vb6 project to vb/net and I have I'm getting an error saying
name 'adStateOpen' is not declared.      

I can find anyting to on how to re-write this.  this code is below

Public Function Clone(ByVal objRecordset As ADODB.Recordset, Optional ByVal LockType As ADODB.LockTypeEnum = ADODB.LockTypeEnum.adLockBatchOptimistic) As ADODB.Recordset
        'RETURNS A CLONE (COPY OF AN EXISTING RECORDSET)
 
        Dim objNewRS As New ADODB.Recordset
        Dim objField As Object
        Dim lngCnt As Long
 
        On Error GoTo LocalError
 
        objNewRS.CursorLocation = ADODB.CursorLocationEnum.adUseClient
        objNewRS.LockType = LockType
 
        For Each objField In objRecordset.Fields
            objNewRS.Fields.Append(objField.Name, objField.Type, objField.DefinedSize, objField.Attributes)
        Next objField
 
        If Not objRecordset.RecordCount = 0 Then
            objNewRS.ActiveConnection = objRecordset.ActiveConnection
            objNewRS.Open()
 
            objRecordset.MoveFirst()
            While Not objRecordset.EOF
                objNewRS.AddNew()
                For lngCnt = 0 To objRecordset.Fields.Count - 1
                    objNewRS.Fields(lngCnt).Value = objRecordset.Fields(lngCnt).Value
                Next lngCnt
                objRecordset.MoveNext()
            End While
            objNewRS.MoveFirst()
        End If
 
        Clone = objNewRS
        Exit Function
 
LocalError:
        m_sLastError = Err.Number & " - " & Err.Description
 
 
        If objNewRS.State = adStateOpen Then
            objNewRS.Close()
        End If
        objNewRS = Nothing
    End Function

Open in new window

0
Comment
Question by:keptins
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 500 total points
ID: 21778743
Hello keptins,

The best solution would be to rewrite the whole shooting match with ADO.Net (not ADODB methods).

Now I realise that at this point you probably don't want to do that so the solution is to use the relevant values (either numerical ones or from the relevant enum).

If objNewRS.State = System.Data.ConnectionState.Open Then

And so on.

Regards,

TimCottee
0
 

Author Comment

by:keptins
ID: 21778765
I'm hoping to learn ADO.net in the very near future...do you recommend any books?
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

618 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