Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO Error Accessing SQL Server 2000 from VFP Code

Status
Not open for further replies.

VBFOXDEV35

Programmer
Mar 26, 2001
77
US
All:

This is driving me crazy. I have the following code to access as SQL server table:

LOCAL oAdoConn
LOCAL oADORs
oAdoConn = CREATEOBJECT("ADODB.CONNECTION")
oAdoConn.Provider = "SQLOLEDB"
oAdoConn.Connectionstring = "user ID = adegaeta;initial Catelog = ISD_Deals;Data Source=CGIDEVW2K;Connect Timeout = 60"
oADOConn.Open
** step #1
** copy the deal information to the menu section of this new program
IF oADOConn.State <> 1 then
Messagebox(&quot;Error Connecting to Data Source=CGIDEVW2K,
Aborting ISD Install&quot;, 64, &quot;Notice&quot;)
oADOConn.Close
oADOConn = 0
CLOSE DATABASES
CLOSE ALL
RELEASE ALL
RETURN
ENDIF

The connection is established however when I perform the following recordset code I get the infamous
&quot;OLE Idispatch exception code 0 from Microsoft OLE DB Provider for SQL Server: Invalid Object Name &quot;tblISDDealInfo&quot;

ON ERROR
SET STEP ON
oADORs = CREATEOBJECT(&quot;ADODB.Recordset&quot;)
oADORs.ActiveConnection = oADOConn
oADORs.Source = &quot;Select * from tblISDDealInfo&quot;
oADORs.CursorType = 2
oADORs.LockType = 3
oADORs.Open

Do anyone have any idea what could be causing this problem. I can use Enterprise manager and perform queries, data access, etc from my workstation. But why is the code returning this error? I cannot seem to trace why. I have changed cursor types, lock types, and still no luck.

Thanks for any help on this.

Art
Art DeGaetano II
Software Developer, MOUS
 
Oh yes, I do have
#INCLUDE &quot;C:\MakeDeal\SFX\adovfp.h&quot;

at the top of my form. Art DeGaetano II
Software Developer, MOUS
 
A few things to check and try.

1. Try fully qualifying the table name

select * from database.owner.tablename

2. Is it possible the server was set up as case sensitive? In which case the object names would also be case sensitive.

3. It might just be in your post but you have a typo in your connection string. It should be Initial Catalog not Catelog.

 
OK, I have just qualified the table as you suggestion in #1, but now when I check the recordcount I get -1. This is odd because I have 2 test records in my table.

Is there any other reason why I am getting recordcount -1?

Thanks

Art
Art DeGaetano II
Software Developer, MOUS
 
As of ADO 2.0, Dynamic cursors do NOT support the recordcount property because it's value can change. You'll need to use a Keyset or Static cursor.

oADORs.CursorType = 1 && 3 for a Static Jon Hawkins
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top