ADO RecordSet open error

ADO RecordSet open error

Postby James Bott » Thu Jul 15, 2010 3:12 pm

Does anyone know why I am getting this error?

Code: Select all  Expand view
  oRs:= createObject("ADODB.RecordSet")
   msginfo( valtype(oRS) )  // returns "O"
   oRs:Open()
   
   I get this error on the last line above:

   Error description: Error ADODB.RecordSet/6  DISP_E_UNKNOWNNAME: OPEN


I am using FWH ver 10.3 with xHarbour.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: ADO RecordSet open error

Postby Rick Lipkin » Thu Jul 15, 2010 4:30 pm

James

Start here when you define your object .. then you can add additional parameters as I have .. I would definitly use the local cache option when you create your recordset .. being local makes listboxes just really fast.

Rick Lipkin

Code: Select all  Expand view

oRs := TOleAuto():New( "ADODB.Recordset" )
 



Code: Select all  Expand view

cSQL := "SELECT * from GAS where AGENEID = '"+xAGENEID+"' order by DATE,LICENSE desc"

oRs := TOleAuto():New( "ADODB.Recordset" )
oRs:CursorType     := 1        // opendkeyset
oRs:CursorLocation := 3        // local cache
oRs:LockType       := 3        // lockoportunistic

TRY
   oRs:Open( cSQL,'Provider='+xPROVIDER+';Data Source='+xSOURCE+';Initial Catalog='+xCATALOG+';User Id='+xUSERID+';Password='+xPASSWORD )
CATCH oErr
   MsgInfo( "Error in Opening GAS table" )
   oDlg:End()
   RETURN(.F.)
END TRY
 
User avatar
Rick Lipkin
 
Posts: 2665
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: ADO RecordSet open error

Postby nageswaragunupudi » Thu Jul 15, 2010 5:49 pm

Mr. Rick

When CursorLocation is 3 ( adUseClient) the RecordSet is always opened as Static. No use specifying keyset or dynamic.

After opening please check
? oRs:CursorType.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10628
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: ADO RecordSet open error

Postby nageswaragunupudi » Thu Jul 15, 2010 5:53 pm

Mr James

For opening recordset, minimum *two things should be specified.
1. Source ( Sql statement, Table name, URL ). In our case mostly sql statement
2. Either connection object or connection string.

Either we can specify then initially:
oRs:Source := <sql statement>
oRs:ActiveConnection := oCon
and then
oRs:Open() .. works

Or

oRs:Open( <cSqlStatement>, <ConnObject>/<ConnString> ) also works.

Please review testxbr3.prg. Opens connection to Access database ( test.mdb ) in the \fwh\samples folder and opens recordsets.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10628
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: ADO RecordSet open error

Postby James Bott » Thu Jul 15, 2010 6:11 pm

Rao,

I have tried testxbr3.prg and it works fine. This is using an Access database. I note that this code calls oRs:Open() without any parameters and it doesn't error out.

The other test code you provided is using a DBF database. This is the one that errors out on the oRs:Open() call (with or without parameters).

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: ADO RecordSet open error

Postby Gale FORd » Thu Jul 15, 2010 9:20 pm

I have to open Access databases and Progress databases. I get that error if I get the connect string wrong or the DSN entry is wrong. Those semicolons and sometimes spaces really mean something.

Here is a DSN-less connect string I use for an Access database that does not need username and password.

cConnectString := [DRIVER={Microsoft Access Driver (*.mdb)};dbq=\\Trg210\webcenter\Database\webcenter40.mdb;]
cSqlString := [Select * From Customers Where Customers.Active ='Yes' AND Customers.Customer_Username = 'gale']
oRecordSet := CreateObject( "ADODB.Recordset" )
oRs := oRecordSet:Open( cSqlString, cConnectString, 0, 1 )
Gale FORd
 
Posts: 663
Joined: Mon Dec 05, 2005 11:22 pm
Location: Houston

Re: ADO RecordSet open error

Postby James Bott » Fri Jul 16, 2010 1:22 am

Gale,

I is not the connection that is the problem. The problem turns out to be that the WHERE clause in the SELECT statement is causing the crash. For more details see this thread.

viewtopic.php?f=3&t=19334&start=30

Rao, is not having the same problem. We have not figured out why I am.

Thanks for the suggestions.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: ADO RecordSet open error

Postby Enrico Maria Giordano » Fri Jul 16, 2010 9:39 am

James Bott wrote:Does anyone know why I am getting this error?


Can you show the exact sample you are trying?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: ADO RecordSet open error

Postby James Bott » Fri Jul 16, 2010 11:42 am

Enrico,

It is in the third message on this page:

viewtopic.php?f=3&t=19334&start=30

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: ADO RecordSet open error

Postby Enrico Maria Giordano » Fri Jul 16, 2010 3:36 pm

Your sample works fine here as it is.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: ADO RecordSet open error

Postby Armando » Fri Jul 16, 2010 4:03 pm

James:

Just an idea, do have the ado heder included ?

#Include "Ado.ch"

Regards
SOI, s.a. de c.v.
estbucarm@gmail.com
http://www.soisa.mex.tl/
http://sqlcmd.blogspot.com/
Tel. (722) 174 44 45
Carpe diem quam minimum credula postero
User avatar
Armando
 
Posts: 3217
Joined: Fri Oct 07, 2005 8:20 pm
Location: Toluca, México

Re: ADO RecordSet open error

Postby James Bott » Fri Jul 16, 2010 4:48 pm

Armando,

I didn't have the ado.ch header included, but I just added it and I still get the same error.

Thanks for the idea.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: ADO RecordSet open error

Postby nageswaragunupudi » Fri Jul 16, 2010 5:04 pm

James Bott wrote:Armando,

I didn't have the ado.ch header included, but I just added it and I still get the same error.

Thanks for the idea.

James

including or not including ado.ch does not make any difference because the program does not use any constants defined in the ado.ch.
ado.ch contains just definitions of constants.

The issue is :
No problem with connection. Connection is getting established.
Even recordset can be opened as long as sql statement does not contain 'WHERE' or 'ORDER' clause.

The reasons to be found is why WHERE and ORDER clauses are failing and that too only on Mr. James PC.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10628
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: ADO RecordSet open error

Postby James Bott » Fri Jul 16, 2010 5:06 pm

Rao,

Actually, the ORDER clause is working. That error was caused by a syntax error on my part. Only the WHERE clause is not working.

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 69 guests

cron