-
-----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()
-
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!
-
 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
-
and here is vb classic so u must put your code in .net section
-
 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
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|