Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ADO and cursoradaptor problem! Anybody??
Message
From
24/05/2004 10:36:45
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Internet applications
Title:
ADO and cursoradaptor problem! Anybody??
Miscellaneous
Thread ID:
00906520
Message ID:
00906520
Views:
48
I would really appreciate some help here.

I have a table in a SQL server database on some site on the internet. I'm using ADO and the cursoradaptor to access the data. I can select the data, but I can’t update, insert or delete data. Can you please point me in the right direction here. I have included my code to select data. It works but I'm not sure if it is the best method.

Thanks in advance.

Code
LOCAL loConn AS ADODB.CONNECTION, ;
loCommand AS ADODB.COMMAND, ;
loException AS EXCEPTION, ;
loCursor AS CURSORADAPTER, ;
laErrors[1]

SET MULTILOCKS ON
loConn = NEWOBJECT("ADODB.CONNECTION")
WITH loConn
.CONNECTIONSTRING = ("DRIVER=SQL Server;Network=DBMSSOCN;SERVER=myserver.com;database=mydata;uid=myid;pwd=mypwd")

TRY
.OPEN
CATCH TO loException
= MESSAGEBOX(loException.MESSAGE)
CANCEL
ENDTRY

ENDWITH



loCommand = CREATEOBJECT('ADODB.COMMAND')
loCursor = CREATEOBJECT('CURSORADAPTER')

WITH loCursor
.ALIAS = 'tbltest'
.DATASOURCETYPE = 'ADO'
.DATASOURCE = CREATEOBJECT('ADODB.RECORDSET')
.SELECTCMD = 'select * from tbltest where region = 2 and id = 5'
.DATASOURCE.ACTIVECONNECTION = loConn
loCommand.ActiveConnection = loConn
IF .CURSORFILL (.F., .F., 0, loCommand)
BROWSE
ELSE
AERROR(laErrors)
MESSAGEBOX(laErrors[2])
ENDIF

* .DeleteCmdDataSourceType = 'ADO'
* .deletecmd = 'delete from tbltest where id = 5'
* .DATASOURCE.ACTIVECONNECTION = loConn
* .DATASOURCE.ACTIVECONNECTION = loConn
* loCommand.ActiveConnection = loConn
* ? .cursorstatus
*WAIT WINDOW
* .cursorrefresh
ENDWITH
Stuart Reid

True nobility lies not in being superior to another man, but in being superior to one’s previous self
Next
Reply
Map
View

Click here to load this message in the networking platform