Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ADO and cursoradaptor problem! Anybody??
Message
General information
Forum:
Visual FoxPro
Category:
Internet applications
Miscellaneous
Thread ID:
00906520
Message ID:
00906553
Views:
17
Stuart,

There are some settings for the recordset that you should be specifying here. By default, a recordset is read only and forward only unless the cursortype is specified. I think you want to actually declare and create your ado recordset, then set it's specfic settings (to make it updateable, what kind of locking to use, etc...) before your with/endwith and specify it in the datasource. Something like this.

local loRs as adodb.recordset

loRs = createobject("adodb.recordset")
loRs.CursorType = 3 && Dynamic
loRs.LockType = 2 && Pessimistic Locking

then later in your code

.DATASOURCE = loRs

For further information on cursor types in ADO, take a look at:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdprocursortype.asp

regards,

JE



>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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform