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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Everything about ADO

Status
Not open for further replies.

dickylam

IS-IT--Management
Jun 24, 2001
86
Anybody can help me.

I use VFP as front -end and user interface. I use SQL 2000 as datbase.

I created adodb.connection and adodb.recordset
Let say,

xobj = createobject("adodb.connectio")
zobj = createobject("adodb.recordset")

However, I do not the syntax how to write open as I tried many...

Suppose, I type:-

zobj.open("table",xobj)

the system will show something (OLE IDispatch exception code 0 ....)

what's wrong on my command ?

please
 
hello rgbean,

Thanks for your advise. However, these document I have seen before and feel too old, do you have other newer articles for reference.
 
I tested this code against SQL 7 via Fox 7 but it should work with SQL 2000 as long as the driver is the same. Anyway it is simple to create the connectstring by doing this:create a blank file called server.udl
open the file by typing server.udl in windows - start/run
follow prompts and create connection string. Then notepad the server.udl file and extract the connectionstring. In the sample below the Catalog is the database your are connecting to. The actual table is in the oRst.Open sql statement select * from ...

Here is a basic program that worked for me with obvious items changed to protect the innocent:


oCon=CREATEOBJECT("ADODB.connection")
oCon.CursorLocation= 3 && adUseClient
oCon.Open("Provider=SQLOLEDB.1;Password=password;Persist Security Info=True;User ID=sa;Initial Catalog=myDatabase;Data Source=192.168.1.1")

oRst=CREATEOBJECT("ADODB.recordset")
oRST.ActiveConnection=oCon
oRst.Open("SELECT * FROM myTable")

DO WHILE !oRst.EOF
?oRst.Fields.Item(0).Value
?oRst.Fields.Item(1).Value
?oRst.Fields.Item(3).Value
oRst.movenext
ENDDO

oRst.Close
oCon.Close
oRst=NULL
oCon=NULL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top