FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour ADO RecordSet open error
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
ADO RecordSet open error
Posted: Thu Jul 15, 2010 03:12 PM
Does anyone know why I am getting this error?

Code (fw): Select all Collapse
   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
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: ADO RecordSet open error
Posted: Thu Jul 15, 2010 04: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 (fw): Select all Collapse
oRs := TOleAuto():New( "ADODB.Recordset" )



Code (fw): Select all Collapse
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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: ADO RecordSet open error
Posted: Thu Jul 15, 2010 05: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
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: ADO RecordSet open error
Posted: Thu Jul 15, 2010 05: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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: ADO RecordSet open error
Posted: Thu Jul 15, 2010 06: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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 663
Joined: Mon Dec 05, 2005 11:22 PM
Re: ADO RecordSet open error
Posted: Thu Jul 15, 2010 09: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 )

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: ADO RecordSet open error
Posted: Fri Jul 16, 2010 01: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=3t=19334start=30

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

Thanks for the suggestions.

James

&&

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: ADO RecordSet open error
Posted: Fri Jul 16, 2010 09:39 AM
James Bott wrote:Does anyone know why I am getting this error?


Can you show the exact sample you are trying?

EMG
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: ADO RecordSet open error
Posted: Fri Jul 16, 2010 11:42 AM

Enrico,

It is in the third message on this page:

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

James

&&

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: ADO RecordSet open error
Posted: Fri Jul 16, 2010 03:36 PM

Your sample works fine here as it is.

EMG

Posts: 3358
Joined: Fri Oct 07, 2005 08:20 PM
Re: ADO RecordSet open error
Posted: Fri Jul 16, 2010 04: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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: ADO RecordSet open error
Posted: Fri Jul 16, 2010 04: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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: ADO RecordSet open error
Posted: Fri Jul 16, 2010 05: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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: ADO RecordSet open error
Posted: Fri Jul 16, 2010 05: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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10

Continue the discussion