DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: -----error------urgent help

  1. #1
    Join Date
    Jan 2007
    Posts
    6

    -----error------urgent help

    i am getting in the bold line and the error is "Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another."
    how can i resolve this
    trQry = "Select * from OPTIMIZER"
    'Connection String
    strConnection = ("provider=sqloledb;Server=VSDOMAIN;database=IDCExtract;Uid=sa;")
    Dim cnAp As OleDb.OleDbConnection
    cnAp = New OleDb.OleDbConnection(strConnection)
    cnAp.Open()
    If cnAp.State = ConnectionState.Open Then
    MsgBox("Connection is open")
    ElseIf cnAp.State = ConnectionState.Closed Then
    MsgBox("Connection is colsed")
    End If
    rs = New ADODB.Recordset
    rs.Open(strQry, cnAp, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic)
    iFreeFile = FreeFile()
    file_name = "c:\abc1.txt"
    FileOpen(iFreeFile, file_name, OpenMode.Append)

    For i = 0 To rs.Fields.Count - 1
    Print(iFreeFile, rs.Fields(i).Name & ";")
    Next
    Print(iFreeFile, "")

    For i = 0 To rs.RecordCount - 1
    For j = 0 To rs.Fields.Count - 1
    Print(iFreeFile, rs.Fields(j).Value & ",")
    Next
    Print(iFreeFile, "")
    rs.MoveNext()
    Next
    ' Close(iFreeFile)
    rs.Clone()
    rs = Nothing
    cnAp.Close()

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Any time you assign a variable using the "New" keyword, you must also use "Set." So you need to change these two lines:

    cnAp = New OleDb.OleDbConnection(strConnection)
    rs = New ADODB.Recordset

    to this:

    Set cnAp = New OleDb.OleDbConnection(strConnection)
    Set rs = New ADODB.Recordset

    See if that helps.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  3. #3
    Join Date
    Jan 2007
    Posts
    6
    Quote Originally Posted by Phil Weber
    Any time you assign a variable using the "New" keyword, you must also use "Set." So you need to change these two lines:

    cnAp = New OleDb.OleDbConnection(strConnection)
    rs = New ADODB.Recordset

    to this:

    Set cnAp = New OleDb.OleDbConnection(strConnection)
    Set rs = New ADODB.Recordset

    See if that helps.
    hi it does'nt work for vb.net
    i am using vb.net

  4. #4
    Join Date
    Oct 2005
    Posts
    1,819
    and here is vb classic so u must put your code in .net section

  5. #5
    Join Date
    Aug 2004
    Location
    Orange, California
    Posts
    1,263
    Quote Originally Posted by him_mca
    how can i resolve this
    trQry = "Select * from OPTIMIZER"
    ....
    rs.Open(strQry, cnAp, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.LockTypeEnum.adLockOptimistic
    Phil is of course correct about missing the Set for your object assignments at least for VB6; but I also noticed that if this code is exactly what is in your program then you have also mistyped the variable name for the select statement. It should be strQry not trQry

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center