topic
stringlengths
1
63
text
stringlengths
1
577k
ADO no me funciona en una tabla en especifico
Julio como el link de las classes esta roto, no puedo hacer pruebas directas lo que te mande fue con la conversion de la tabla, por lo que comento que la tabla esta bien. puedes subirlo a: <!-- m --><a class="postlink" href="ftp://proyectos.ita.mx">ftp://proyectos.ita.mx</a><!-- m --> usuario:fer pasword:fer o enviamela por correo. saludos fernando snadoval ruiz
ADO no me funciona en una tabla en especifico
Por favor, los ficheros que intercambieis alojadlos en <!-- w --><a class="postlink" href="http://www.hyperupload.com">www.hyperupload.com</a><!-- w --> y publicar aqui el enlace de descarga para que asi otros usuarios puedan acceder a ellos. gracias.
ADO no me funciona en una tabla en especifico
Bueno, este es el final de este capitulo de la trilogía "ADO y yo" ! El asunto esta solucionado. Son tantas las consideraciones y aprendizajes con esto que me paso, que creo que estaré escribiendo algo mas amplio en mi recién abierto blog. Intentaré resumir aquí algunos puntos importantes para los "foronautas": - Despues de buscar mucho entre las opciones para hacer el OPEN en el RS y en la conexion, confirmo que las mejores son las que aparecen en el ejemplo de JLC. - El asunto estaba en la forma de "grabar" el registro en el recordset, que para los fines de la clase ADORS se trata de errores cometidos por mi en el método SAVE(). El grabar en el recordset es uno de los aspectos mas delicados que he encontrado en ADO. - El mensaje que aparecia era consecuencia de que el RS se "cerraba" cuando se hacia una sustitucion que no le gustaba. Mucha luz me trajo a esto el nuevo amigo Fernando Sandoval, cuando me invitó a verificar el tipo de datos que quiero "grabar" y el tipo de datos de la columna que quiero que los acepte. - El problema se concentraba en los campos tipo fecha. Intentaba escribir una fecha en un campo que el ADO lo interpretó como de tipo "indefinido". Lo descubrí haciendo VALTYPE( ::oRs:Fields("Fecha"):value ) sobre una fecha en blanco, pues me devolvía "U", mientras que cuando el registro tenía una fecha correcta, me devolvía "D". Fue entonces que, por sugerencia de FS evité realizar esta sustitución. Aun me falta probar un poco mas con este caso, pero ya está controlado. - La otra cosa, fue la pregunta clave: "¿UPDATE o no UPDATE?".... pues cuando el registro no ha sido cambiado, no debe hacerse. JLC me sugirió en otra parte del foro una manera de realizarlo, pero no me funcionó, así que lo implementé localmente dentro del método SAVE(), y funciona perfectamente. Estaré probando otras cosas durante la Semana Santa: - manejo de campos MEMO (BLOB?, TEXT?) - Generacion de reportes - manejo de ADO por internet, etc. Asi que por ahora, este capítulo lo considero cerrado. Estaré también publicando las clases modificadas de JLC en mi blog ([url:27i3ejgs]http&#58;//mangucybernetico&#46;blogspot&#46;com/[/url:27i3ejgs]) para los que estén interesados, mas un ejemplo realizado por mi para demostrarme a mi mismo la potencia maravillosa del uso de ADO en todo esto. Gracias a todos, en especial a JLC y FS por su paciencia, y sera hasta otro capítulo. .... Y LA SAGA CONTINUA !!!!
ADO não funciona o RecordCount()?
Ola pessoal, estou trabalhando com o ADO para o ACCESS porem alguns comandos conforme relação abaixo não funciona! sabem porque? **************************************************** #Include "Fivewin.ch" Function Main() LOCAL oDados, txSql PRIVATE oCn := CREATEOBJECT( "ADODB.Connection" ) oCn:Open( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=venda.mdb" ) txSql := "SELECT * FROM imovweb; " oDados := oCn:Execute( txSql) oDados:MoveNext() -- Funciona oDados:MoveFirst() -- NÃO Funciona oDados:MoveLast() -- NÃO Funciona oDados:RecordCount() -- NÃO Funciona ****************************************************
ADO não funciona o RecordCount()?
Ola pessoal, estou trabalhando com o ADO para o ACCESS porem alguns comandos conforme relação abaixo não funciona! sabem porque? **************************************************** #Include "Fivewin.ch" Function Main() LOCAL oDados, txSql PRIVATE oCn := CREATEOBJECT( "ADODB.Connection" ) oCn:Open( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=venda.mdb" ) txSql := "SELECT * FROM imovweb; " oDados := oCn:Execute( txSql) oDados:MoveNext() -- Funciona oDados:MoveFirst() -- NÃO Funciona oDados:MoveLast() -- NÃO Funciona oDados:RecordCount() -- NÃO Funciona ****************************************************
ADO não funciona o RecordCount()?
From the MSDN: "The returned Recordset object is always a read-only, forward-only cursor." Use recordsets instead of connections: [code:2nkza2xb]#define adOpenForwardOnly 0 #define adOpenKeyset 1 #define adOpenDynamic 2 #define adOpenStatic 3 #define adLockReadOnly 1 #define adLockPessimistic 2 #define adLockOptimistic 3 #define adLockBatchOptimistic 4 FUNCTION MAIN&#40;&#41; LOCAL oRs &#58;= CREATEOBJECT&#40; "ADODB&#46;Recordset" &#41; oRs&#58;Open&#40; "SELECT * FROM Clienti", "Provider=Microsoft&#46;Jet&#46;OLEDB&#46;4&#46;0;Data Source=clienti&#46;mdb", adOpenKeyset, adLockReadOnly &#41; oRs&#58;MoveLast&#40;&#41; WHILE !oRs&#58;EOF ? oRs&#58;Fields&#40; "Cliente" &#41;&#58;Value oRs&#58;MoveNext&#40;&#41; ENDDO oRs&#58;Close&#40;&#41; INKEY&#40; 0 &#41; RETURN NIL[/code:2nkza2xb] EMG
ADO não funciona o RecordCount()?
Perfect! Muito obrigado, Ronaldo Minacapelli
ADO não funciona o RecordCount()?
Ronaldo, ¿Donde tienes el cursor? ¿¿Que valor tiene CursorLocation del objeto Connection?? Saludos, José Luis Capel
ADO não funciona o RecordCount()?
No uses objetos CONNECTION para ejecutar el query, los objetos CONNECTION regresan un cursor forward que no puede recuperar los valores que necesitas. Crea un objeto Connection, luego un objeto Command y eso te devolvera el RecordSet que necesitas.
ADO não funciona o RecordCount()?
René, [quote:37sla978]No uses objetos CONNECTION para ejecutar el query, los objetos CONNECTION regresan un cursor forward que no puede recuperar los valores que necesitas.[/quote:37sla978] No es exactamente como tu dices. El método execute del objeto Connection devuelve siempre un recordset del tipo y localización que has indicado en la creación del objeto Connection (y si no se indican, se utilizan los valores por defecto). [quote:37sla978]Crea un objeto Connection, luego un objeto Command y eso te devolvera el RecordSet que necesitas.[/quote:37sla978] Tampoco es exactamente así. Si vas a trabajar con resultados de datos (filas y columnas) es preferible siempre utilizar el objeto Recordset y reservar el objeto Command para llamadas a procedimientos almacenados y otras funciones de servidor. Saludos, José Luis Capel
ADO não funciona o RecordCount()?
Ronaldo, Prueba este código a ver si te ayuda a clarificar por que no te funcionan los métodos que indicas: [code:1bllbe90]#Include "Fivewin&#46;ch" #define adBookmark 0x2000 #define adMovePrevious 0x200 Function Main&#40;&#41; LOCAL oDados, txSql PRIVATE oCn &#58;= CREATEOBJECT&#40; "ADODB&#46;Connection" &#41; oCn&#58;Open&#40; "Provider=Microsoft&#46;Jet&#46;OLEDB&#46;4&#46;0;Data Source=venda&#46;mdb" &#41; txSql &#58;= "SELECT * FROM imovweb; " oDados &#58;= oCn&#58;Execute&#40; txSql&#41; MsgInfo&#40; IIF&#40;oDados&#58;Supports&#40;adBookmark&#41;,"Soporta RecordCount","No soporta RecordCount"&#41;&#41; MsgInfo&#40; IIF&#40;oDados&#58;Supports&#40;adMovePrevious&#41;,"Soporta MoveFirst, MovePrevious, etc","No soporta MoveFirst, MovePrevious, etc"&#41;&#41; &#46;&#46;&#46;&#46; [/code:1bllbe90] No lo he probado... Espero que esto te ayude. Saludos, José Luis Capel
ADO não funciona o RecordCount()?
Hi enrico.. Do you Know , Where Find Mtehods and DATA from this Class.. CREATEOBJECT( "ADODB.Recordset" ) Thanks
ADO não funciona o RecordCount()?
On the MSDN. EMG
ADO não funciona o RecordCount()?
Thanks Enrico... I´m Learn About ADO, But You Can Response Only Two Asks? First .. Using ADODB My Systems Are Compatible With win98 , winxp , win2003 ? Second.. Using ADODB My Systems Required DATABASE registre in ODBC ?
ADO não funciona o RecordCount()?
1) WinXP and Win2003: yes. Win98: you will need to install Office or MSDE. 2) No. EMG
ADO não funciona o RecordCount()?
Thanks Very Much Enrico. Mauricio
ADO não funciona o RecordCount()?
[quote="EnricoMaria":1u5q0l6s]1) WinXP and Win2003: yes. Win98: you will need to install Office or MSDE.[/quote:1u5q0l6s] Sorry, MDAC not MSDE. EMG
ADO não funciona o RecordCount()?
Thanks Enrico AGAIN... i´m modify TCBROWSE to ADO How Get Field Names of Database Using ADO ? thanks Mauricio
ADO não funciona o RecordCount()?
[code:hyoifeh7]#define adOpenForwardOnly 0 #define adOpenKeyset 1 #define adOpenDynamic 2 #define adOpenStatic 3 #define adLockReadOnly 1 #define adLockPessimistic 2 #define adLockOptimistic 3 #define adLockBatchOptimistic 4 FUNCTION MAIN&#40;&#41; LOCAL oCat LOCAL i, j oCat = CREATEOBJECT&#40; "ADOX&#46;Catalog" &#41; oCat&#58;ActiveConnection = "Provider=SQLOLEDB;Integrated Security=SSPI;Data Source=EMAG\Emag;Initial Catalog=Quadro" FOR i = 0 TO oCat&#58;Tables&#58;Count&#40;&#41; - 1 ? oCat&#58;Tables&#40; i &#41;&#58;Name ? FOR j = 0 TO oCat&#58;Tables&#40; i &#41;&#58;Columns&#58;Count&#40;&#41; - 1 ? SPACE&#40; 4 &#41; + oCat&#58;Tables&#40; i &#41;&#58;Columns&#40; j &#41;&#58;Name NEXT ? NEXT RETURN NIL[/code:hyoifeh7] EMG
ADO não funciona o RecordCount()?
Enrico , The Object Change ADO for ADOX because You are Using Extend ADO methods, Thats Right? The Extende ADO methods are 100% compatible ? thanks , AGAIN mauricio (brazil)
ADO não funciona o RecordCount()?
[quote="mauricioajordao":10ldrvt6]Enrico , The Object Change ADO for ADOX because You are Using Extend ADO methods, Thats Right? The Extende ADO methods are 100% compatible ?[/quote:10ldrvt6] Yes and yes. EMG
ADO não funciona o RecordCount()?
THANKS AGAIN MAURICIO
ADO não funciona o RecordCount()?
Hola : proba asi si usas Ado oData1:RecordCount() Asi no funciona If oData1:RecordCount > 0 ? "Hay " EndIf
ADO não funciona o RecordCount()?
A mi me funciona Asi. COn Mysql if oDatos:RecordCount() =0 //ADORecCount() MsgInfo("No Hay Datos ","Informacion") Return (.t.) endif nLinea := 1 ; nHasta := oDatos:RecordCount() oDatos:MoveFirst()
ADO não funciona o RecordCount()?
Por qué no usas un recordset. Prueba así: **************************************************** #Include "Fivewin.ch" Function Main() LOCAL txSql PRIVATE oCn,oRs,oError //Crea el objeto conexión TRY oCn := TOleAuto():new("adodb.connection") CATCH oError MsgStop( "No se pudo crear el objeto conexión !") RETURN(.F.) END //Crea el objeto recordset que manejará la tabla TRY oRs := TOleAuto():New("adodb.recordset") CATCH oError MsgStop( "No se pudo crear el recordset) RETURN .f. END //Abrimos la conexión TRY oCn:Open( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=venda.mdb" ) CATCH oError MsgStop( "No se pudo abrir la conexión !") return .f. END //Configuramos el recordset que manejara la tabla oRs:CursorLocation := adUseClient oRs:LockType := adLockOptimistic oRs:CursorType := adOpenKeyset//adOpenDynamic oRs:Source := "SELECT * FROM imovweb; " oRs:ActiveConnection(oCn) //Ahora si cargamos los datos en el recordset TRY oRs:Open() CATCH oError MsgStop( "No se pudo cargar los datos de la Tabla imovweb") RETURN .f. END //asegurarse que la tabla no esté vacía para usar //los métodos que pones de ejemplo if ! oRs:BOF() .AND. ! oRs:EOF() oRs:MoveNext() //-- Funciona oRs:MoveFirst() //-- NÃO Funciona oRs:MoveLast() //-- NÃO Funciona oRs:RecordCount()// -- NÃO Funciona endif ors:Close() oCn:Close() **************************************************** Saludos Marcelo Jingo
ADO não funciona o RecordCount()?
Então, creio que essas opções não funcionem, pois voc~e deve verificar a forma de abertura do RecordSet. Ronaldo Minacapelli
ADO oCn:Backup()
Hola, ¿Sabéis donde puedo encontrar la documentación de sus parámetros? Muchas gracias.
ADO oCn:Backup()
Moises: Dale una revisión a MySqlDump.exe y MySQL.Exe, para hacer el respaldo/recuperación de acuerdo a tus necesidades. Saludos
ADO oCn:Backup()
Muchas gracias por contestar. Busco una aproximación vía ADO para MySQL/MSSQL/María DB, neutral por tanto desde el punto de vista de la base de datos. Creo que existe este método, pero no he encontrado sus parámetros. Un saludo
ADO oCn:Backup()
Moises: Mira este link <!-- m --><a class="postlink" href="https://www.linode.com/docs/databases/mysql/use-mysqldump-to-back-up-mysql-or-mariadb/">https://www.linode.com/docs/databases/m ... r-mariadb/</a><!-- m --> Saludos
ADO oCn:Backup()
Muchas gracias, pero no es lo que busco, porque el backup se tiene que hacer desde el propio programa y usando los métodos de ADO, para que funcione también en MSSQL, SQLite. etc.
ADO open/close Connection Question
Hello, I'm using ADO and at the begin op my program I open a connection to the SQL-server. This program is running for a long time, and sometimes I get a ''MySQL server has gone away'-error. This is always when executing a command like 'INSERT INTO', not with recordsets. With recordsets, I allways create a new recordset when reading data. That was the same problem that I had after resuming al laptop. [url:21sw9dws]http&#58;//forums&#46;fivetechsupport&#46;com/viewtopic&#46;php?f=3&t=28763&p=161537&hilit=connection+laptop#p161537[/url:21sw9dws] Now I was wondering if it would be beter to not open a connection at the beginning of the program and close in at the end, but open a connecion only if i want to execute a SQL-command, like 'INSERT INTO',.. and than close it again. For reading data I allways use a recordset, and than I also open it before reading. Will the program become slower by allways opening and closing a connection? Are there other disadvantages doing this? Are there other people do this also?
ADO open/close Connection Question
Marc, I always open a recodset only when needed. Programs don't slow down. If you have to write a bunch of record then take care to open and close the recordset only once. EMG
ADO open/close Connection Question
Enrico, I always open and close also when using a recordset, but if I want to inset records, or delete records, I don't use recordsets. I use the [code=fw:2ojj9uo6]<div class="fw" id="{CB}" style="font-family: monospace;">oSQL:=CreateObject<span style="color: #000000;">&#40;</span><span style="color: #ff0000;">"ADODB.Connection"</span><span style="color: #000000;">&#41;</span></div>[/code:2ojj9uo6] and then [code=fw:2ojj9uo6]<div class="fw" id="{CB}" style="font-family: monospace;">oSQL:<span style="color: #000000;">execute</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span></div>[/code:2ojj9uo6] command. Do you use also recordsets for adding and deleting records?
ADO open/close Connection Question
Marc, If you don't use recordsets you still need to open and close connections. EMG
ADO open/close Connection Question
[quote="Enrico Maria Giordano":1see933g]Marc, If you don't use recordsets you still need to open and close connections. EMG[/quote:1see933g] Enrico, That was my question. Now I'm opening the connection at the beginning of the program, and close it at exit. The problem is that sometimes when the program is a long time active, that the coenction is gone, and I was modering if it will be better instead of opening it at the beginning of the program, that I open the connectecion just before executing a SQL-command, and direct close it again.
ADO open/close Connection Question
Marc, your best option is to open che connection just before the call to one or more Execute() methods and to close it at the end. EMG
ADO open/close Connection Question
[quote="Enrico Maria Giordano":28hny0hm]Marc, your best option is to open che connection just before the call to one or more Execute() methods and to close it at the end. EMG[/quote:28hny0hm] Thanks Enrico, Just one more question. Is is the best that solution that 1 onlo use [quote:28hny0hm]oSQL:=CreateObject("ADODB.Connection")[/quote:28hny0hm] at the beginning op the program, and then use [code=fw:28hny0hm]<div class="fw" id="{CB}" style="font-family: monospace;">oSQL:<span style="color: #000000;">Open</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />oQry=oSQL:<span style="color: #000000;">execute</span><span style="color: #000000;">&#40;</span>.....<span style="color: #000000;">&#41;</span><br />oSQL:<span style="color: #000000;">close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />....<br />oSQL:<span style="color: #000000;">Open</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />oQry=oSQL:<span style="color: #000000;">execute</span><span style="color: #000000;">&#40;</span>.....<span style="color: #000000;">&#41;</span><br />oSQL:<span style="color: #000000;">close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />....<br />oSQL:<span style="color: #000000;">Open</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />oQry=oSQL:<span style="color: #000000;">execute</span><span style="color: #000000;">&#40;</span>.....<span style="color: #000000;">&#41;</span><br />oSQL:<span style="color: #000000;">close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br /><br />oSQL:=<span style="color: #00C800;">nil</span><br /> </div>[/code:28hny0hm] or always do[code=fw:28hny0hm]<div class="fw" id="{CB}" style="font-family: monospace;">oSQL:=CreateObject<span style="color: #000000;">&#40;</span><span style="color: #ff0000;">"ADODB.Connection"</span><span style="color: #000000;">&#41;</span><br />oSQL:<span style="color: #000000;">Open</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />oQry=oSQL:<span style="color: #000000;">execute</span><span style="color: #000000;">&#40;</span>.....<span style="color: #000000;">&#41;</span><br />oSQL:<span style="color: #000000;">close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />oSQL:=<span style="color: #00C800;">nil</span><br />...<br />oSQL:=CreateObject<span style="color: #000000;">&#40;</span><span style="color: #ff0000;">"ADODB.Connection"</span><span style="color: #000000;">&#41;</span><br />oSQL:<span style="color: #000000;">Open</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />oQry=oSQL:<span style="color: #000000;">execute</span><span style="color: #000000;">&#40;</span>.....<span style="color: #000000;">&#41;</span><br />oSQL:<span style="color: #000000;">close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />oSQL:=<span style="color: #00C800;">nil</span><br />...<br />oSQL:=CreateObject<span style="color: #000000;">&#40;</span><span style="color: #ff0000;">"ADODB.Connection"</span><span style="color: #000000;">&#41;</span><br />oSQL:<span style="color: #000000;">Open</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />oQry=oSQL:<span style="color: #000000;">execute</span><span style="color: #000000;">&#40;</span>.....<span style="color: #000000;">&#41;</span><br />oSQL:<span style="color: #000000;">close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />oSQL:=<span style="color: #00C800;">nil</span><br /> </div>[/code:28hny0hm]
ADO open/close Connection Question
Marc, you can safely use the first option (one only CreateObject()). EMG
ADO question
Hi guys Usually in PHP when I need to insert a record in an SQL table I check first the primary key value to avoid to get an error for duplicate key entry. I'm uploading a .dbf file to a SQL table. The .dbf has values there exist in the SQL table. I'm using the AddNew() and Update() Method but on having tried to insert a duplicate value into the SQL table I get an error of course. How can I check the value before the insert sentence? This is my code [code:27uowtuz] do while !cSource->&#40; Eof&#40;&#41; &#41; // cSQLCommand &#58;= "SELECT * FROM FPPtoNom WHERE PtoNomCod=" + bTrans&#40; AllTrim&#40; cSource->PtoNomCod &#41; &#41; // if oCursor&#58;Open&#40; cSQLCommand, oSQL&#58;oConexion&#58;oConnection &#41; &#46;and&#46; oCursor&#58;oRs&#58;RecordCount = 0 oCursor&#58;oRs&#58;AddNew&#40;&#41; oCursor&#58;oRs&#58;fields&#40;"PtoNomCod"&#41;&#58;value &#58;= AllTrim&#40; cSource->PtoNomCod &#41; oCursor&#58;oRs&#58;fields&#40;"PtoNomAbr"&#41;&#58;value &#58;= AllTrim&#40; cSource->PtoNomAbr &#41; oCursor&#58;oRs&#58;fields&#40;"PtoNomDes"&#41;&#58;value &#58;= AllTrim&#40; cSource->PtoNomDes &#41; oCursor&#58;oRs&#58;fields&#40;"PtoNomtip"&#41;&#58;value &#58;= AllTrim&#40; cSource->PtoNomTip &#41; oCursor&#58;oRs&#58;Update&#40;&#41; // endif cSource->&#40; dBSkip&#40;&#41; &#41; enddo[/code:27uowtuz] Thanks
ADO question: Access is not refresing properly
Hello, I am using an Access 2003 database via ADO in a single PC. Sometimes, when I add the records the recordset is not refreshed, despite the call of oRs:Requery(), even twice. I have to wait 3-4 seconds and after that time it is refreshed. I only experience such behaviour with Access, it is beeing a nighmare. This is the connection string: cStr := 'Provider='+"Microsoft.Jet.OLEDB.4.0"+';Data Source='+cBD And this is how I open the recordset and the database: LOCAL oError DEFAULT cSQL := "SELECT * From TablaInexistente" // open a recordset on demand with sql statement and connection string oRsUser := TOleAuto():New( "ADODB.Recordset" ) oRsUser:CursorType := 1 // opendkeyset oRsUser:CursorLocation := 3 // local cache oRsUser:LockType := 3 // lockoportunistic TRY oRsUser:Open( cSQL, cStr ) oCn := oRsUser:ActiveConnection oRdbms := FW_RDBMSName( oCn ) CATCH oError ado_ErrorNoRecordSet(oError) // Mensaje de Error oRsUser := nil END Maybe opportunistick lock?. But it is not used on network. Any clue please?. Thank you.
ADO question: Access is not refresing properly
Lucas, I am using ADO + Access on a development and I don't call oRs:Requery() when adding a record and here it works fine <!-- s:-) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":-)" title="Smile" /><!-- s:-) --> I use: oRS:MoveLast() oRs:AddNew() fill the right values oRS:Update()
ADO question: Access is not refresing properly
Antonio, [quote="Antonio Linares":lw2j3qoo]oRS:MoveLast() oRs:AddNew() fill the right values oRS:Update()[/quote:lw2j3qoo] You can safely remove oRS:MoveLast(). <!-- s:-) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":-)" title="Smile" /><!-- s:-) --> EMG
ADO question: Access is not refresing properly
Hello, This is a complete test: <!-- m --><a class="postlink" href="http://demo.ovh.es/en/9beda86cc9165fb7bae4af1cd65c05f9/">http://demo.ovh.es/en/9beda86cc9165fb7bae4af1cd65c05f9/</a><!-- m --> Just click on Añadir, and you will see that oRs is not updated: [img:1q01ldrs]http&#58;//i44&#46;tinypic&#46;com/2je4j14&#46;png[/img:1q01ldrs] Thank you. .prg: [code=fw:1q01ldrs]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #B900B9;">//</span><br /><span style="color: #B900B9;">// Test oRs Not refreshing in Access</span><br /><span style="color: #B900B9;">//</span><br /><span style="color: #B900B9;">//---------------------</span><br /><br /><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"FiveWin.ch"</span><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"xbrowse.ch"</span><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"report.ch"</span><br /><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"dbstruct.ch"</span><br /><span style="color: #00D7D7;">#include</span> <span style="color: #ff0000;">"adodef.ch"</span><br /><br /><br /><span style="color: #00C800;">STATIC</span> oCn, cStr<br /><span style="color: #00C800;">STATIC</span> oRsUser, oRdbms &nbsp; &nbsp;<span style="color: #B900B9;">// RecordSet</span><br /><br /><br />REQUEST HB_Lang_ES<br />REQUEST HB_CODEPAGE_ESWIN<br /><br /><span style="color: #B900B9;">//--------------------------------------------------------------------------//</span><br /><br /><br /><br /><span style="color: #B900B9;">// ---------------------------------------------------------------------------</span><br /><span style="color: #00C800;">FUNCTION</span> MAIN<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br /><span style="color: #B900B9;">// ---------------------------------------------------------------------------</span><br /><br />&nbsp; &nbsp;<span style="color: #B900B9;">// Idioma español para Harbour--------------------------------------------</span><br />&nbsp; &nbsp;HB_LangSelect<span style="color: #000000;">&#40;</span><span style="color: #ff0000;">"ESWIN"</span><span style="color: #000000;">&#41;</span> <span style="color: #B900B9;">// Para mensajes, fechas, etc..</span><br />&nbsp; &nbsp;HB_CDPSELECT<span style="color: #000000;">&#40;</span><span style="color: #ff0000;">"ESWIN"</span><span style="color: #000000;">&#41;</span> <span style="color: #B900B9;">// Para ordenación, requiere CodePage.lib</span><br /><br /><br /><br /><br /><br /><br />&nbsp; &nbsp;<span style="color: #B900B9;">// Sets generales---------------------------------------------------------</span><br />&nbsp; &nbsp;SetGetColorFocus<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #B900B9;">// Cambiar el foco del GET</span><br />&nbsp; &nbsp;SET EPOCH <span style="color: #0000ff;">TO</span> <span style="color: #000000;">1990</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #B900B9;">// Admite los años desde el 1990 en adelante</span><br />&nbsp; &nbsp;SET CENTURY <span style="color: #0000ff;">ON</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #B900B9;">// 4 dígitos año</span><br />&nbsp; &nbsp;SET DATE ITALIAN &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #B900B9;">// formato dd-mm-yyyy</span><br />&nbsp; &nbsp;SET DELETED <span style="color: #0000ff;">ON</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #B900B9;">// Impedir ver registros marcados borrar</span><br />&nbsp; &nbsp;SetCancel<span style="color: #000000;">&#40;</span> .F. <span style="color: #000000;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #B900B9;">// Inutiliza ALT + C para abortar programa</span><br />&nbsp; &nbsp;SetDialogEsc<span style="color: #000000;">&#40;</span> .F. <span style="color: #000000;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #B900B9;">// Impide salir Diálogos con Escape</span><br />&nbsp; &nbsp;SET<span style="color: #000000;">&#40;</span> _SET_INSERT, .T. <span style="color: #000000;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #B900B9;">// Activa modo Insert</span><br /><br />&nbsp; &nbsp;XBrNumFormat<span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">"E"</span>, .t. <span style="color: #000000;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #B900B9;">// Picture xBrowse formato Europeo decimales</span><br />&nbsp; &nbsp;SetBalloon<span style="color: #000000;">&#40;</span> .T. <span style="color: #000000;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #B900B9;">// Balloon shape required for tooltips</span><br /><br /><br /><br />&nbsp; &nbsp;ado_string<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br /><br />&nbsp; &nbsp;VerApuntes<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br /><br /><br />QUIT<br /><br /><span style="color: #00C800;">RETURN</span> <span style="color: #00C800;">NIL</span><br /><span style="color: #B900B9;">// ---------------------------------------------------------------------------</span><br /><br /><br /><br /><br /><span style="color: #B900B9;">// ---------------------------------------------------------------------------</span><br /><span style="color: #B900B9;">// Función ....: VerApuntes</span><br /><span style="color: #B900B9;">// Descripción.: Browse en pantalla de los apuntes</span><br /><span style="color: #B900B9;">// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Desde ?l se llaman las opciones de edici¢n, etc</span><br /><span style="color: #B900B9;">// ---------------------------------------------------------------------------</span><br /><span style="color: #00C800;">FUNCTION</span> VerApuntes<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br /><br />&nbsp; &nbsp;<span style="color: #00C800;">LOCAL</span> oDlg, oBrowse<br />&nbsp; &nbsp;<span style="color: #00C800;">LOCAL</span> oBtn1, oBtn2, oBtn3, oBtn4, oBtn5, oBtn6<br /><br />&nbsp; &nbsp;<span style="color: #00C800;">LOCAL</span> oRs<br />&nbsp; &nbsp;<span style="color: #00C800;">LOCAL</span> nPos := <span style="color: #000000;">0</span><br /><br /><br /><br />&nbsp; &nbsp;<span style="color: #B900B9;">//</span><br />&nbsp; &nbsp;<span style="color: #B900B9;">// RecordSet</span><br />&nbsp; &nbsp;<span style="color: #B900B9;">//-----------</span><br />&nbsp; &nbsp;oRs &nbsp; := ado_AbreRecordSet<span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">"select * from APUNTES order by FECHA ASC"</span> &nbsp;<span style="color: #000000;">&#41;</span><br /><br />&nbsp; &nbsp;<span style="color: #00C800;">IF</span> oRs = <span style="color: #00C800;">nil</span><br />&nbsp; &nbsp; &nbsp; <span style="color: #00C800;">RETURN</span> <span style="color: #00C800;">NIL</span><br />&nbsp; &nbsp;<span style="color: #00C800;">ENDIF</span><br /><br /><br /><br /><br /><br />&nbsp; &nbsp;<span style="color: #B900B9;">//</span><br />&nbsp; &nbsp;<span style="color: #B900B9;">// Caja de Diálogo -----------------------------------------------------</span><br />&nbsp; &nbsp;<span style="color: #0000ff;">DEFINE</span> <span style="color: #0000ff;">DIALOG</span> oDlg <span style="color: #0000ff;">RESOURCE</span> <span style="color: #ff0000;">"APUNTES"</span> ;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">TITLE</span> <span style="color: #ff0000;">"Mantenimiento de los APUNTES contables"</span><br /><br /><br />&nbsp; &nbsp;<span style="color: #0000ff;">REDEFINE</span> <span style="color: #0000ff;">XBROWSE</span> oBrowse &nbsp;<span style="color: #0000ff;">ID</span> <span style="color: #000000;">101</span> <span style="color: #0000ff;">OF</span> oDlg ;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DATASOURCE oRs ;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; COLUMNS <span style="color: #ff0000;">"FECHA"</span>, <span style="color: #ff0000;">"CUENTA"</span>, <span style="color: #ff0000;">"APUNTE"</span>, <span style="color: #ff0000;">"NINGRESO"</span>, <span style="color: #ff0000;">"NGASTO"</span>, <span style="color: #ff0000;">"NOTAS"</span> ;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HEADERS <span style="color: #ff0000;">"Fecha"</span>, <span style="color: #ff0000;">"Cuenta"</span>, <span style="color: #ff0000;">"Apunte"</span>, <span style="color: #ff0000;">"Ingreso"</span>, <span style="color: #ff0000;">"Gasto"</span>, <span style="color: #ff0000;">"Observaciones"</span> ;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">AUTOCOLS</span> AUTOSORT CELL LINES<br /><br /><br /><br />&nbsp; &nbsp;<span style="color: #B900B9;">// Estilo-----------</span><br />&nbsp; &nbsp;oBrowse:<span style="color: #000000;">nMarqueeStyle</span> &nbsp; &nbsp; &nbsp; := <span style="color: #000000;">5</span> <span style="color: #B900B9;">//9 // 5 por defecto MARQSTYLE_IDESOFT</span><br />&nbsp; &nbsp;oBrowse:<span style="color: #000000;">nHeaderLines</span> &nbsp; &nbsp; &nbsp; &nbsp;:= <span style="color: #000000;">1.5</span><br />&nbsp; &nbsp;oBrowse:<span style="color: #000000;">nStretchCol</span> &nbsp; &nbsp; &nbsp; &nbsp; := STRETCHCOL_LAST<br />&nbsp; &nbsp;oBrowse:<span style="color: #000000;">lAllowColHiding</span> &nbsp; &nbsp; := .F. &nbsp; <span style="color: #B900B9;">// Impedir tocar columnas</span><br /><br /><br />&nbsp; &nbsp;oBrowse:<span style="color: #000000;">blDblClick</span> := <span style="color: #000000;">&#123;</span> || <span style="color: #000000;">&#40;</span> oBtn3:<span style="color: #0000ff;">Click</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#125;</span><br />&nbsp; &nbsp;oBrowse:<span style="color: #000000;">bKeyDown</span> := <span style="color: #000000;">&#123;</span> | nKey, nFlags | <span style="color: #00C800;">IF</span> <span style="color: #000000;">&#40;</span>nKey==VK_RETURN, oDlg:<span style="color: #000000;">End</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, <span style="color: #000000;">&#41;</span>,;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00C800;">IF</span> <span style="color: #000000;">&#40;</span>nKey==VK_ESCAPE, oDlg:<span style="color: #000000;">End</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#125;</span><br /><br /><br /><br /><br /><br />&nbsp; &nbsp;<span style="color: #0000ff;">REDEFINE</span> <span style="color: #0000ff;">BUTTON</span> oBtn1 <span style="color: #0000ff;">ID</span> <span style="color: #000000;">711</span> <span style="color: #0000ff;">OF</span> oDlg ;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">ACTION</span><span style="color: #000000;">&#40;</span> AltasApuntes<span style="color: #000000;">&#40;</span> .T. <span style="color: #000000;">&#41;</span>, ;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; oRs:<span style="color: #000000;">Requery</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, <span style="color: #0000ff;">xbrowse</span><span style="color: #000000;">&#40;</span>oRs<span style="color: #000000;">&#41;</span>, oBrowse:<span style="color: #0000ff;">Refresh</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, oBrowse:<span style="color: #000000;">SetFocus</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br /><br />&nbsp; &nbsp;<span style="color: #0000ff;">REDEFINE</span> <span style="color: #0000ff;">BUTTON</span> oBtn2 <span style="color: #0000ff;">ID</span> <span style="color: #000000;">712</span> <span style="color: #0000ff;">OF</span> oDlg ;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">ACTION</span><span style="color: #000000;">&#40;</span> ado_Borrar<span style="color: #000000;">&#40;</span> oRs <span style="color: #000000;">&#41;</span>, ;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; oBrowse:<span style="color: #0000ff;">Refresh</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br /><br />&nbsp; &nbsp;<span style="color: #0000ff;">REDEFINE</span> <span style="color: #0000ff;">BUTTON</span> oBtn3 <span style="color: #0000ff;">ID</span> <span style="color: #000000;">713</span> <span style="color: #0000ff;">OF</span> oDlg ;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">ACTION</span><span style="color: #000000;">&#40;</span> nPos := oRs:<span style="color: #000000;">AbsolutePosition</span>, AltasApuntes<span style="color: #000000;">&#40;</span> .F., oRs:<span style="color: #000000;">AbsolutePosition</span> <span style="color: #000000;">&#41;</span>, ;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; oRs:<span style="color: #000000;">Requery</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, oRs:<span style="color: #000000;">AbsolutePosition</span> := nPos, oBrowse:<span style="color: #0000ff;">Refresh</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br /><br />&nbsp; &nbsp;<span style="color: #0000ff;">REDEFINE</span> <span style="color: #0000ff;">BUTTON</span> oBtn4 <span style="color: #0000ff;">ID</span> <span style="color: #000000;">714</span> <span style="color: #0000ff;">OF</span> oDlg ;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">ACTION</span><span style="color: #000000;">&#40;</span> oRs:<span style="color: #000000;">Requery</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>, oBrowse:<span style="color: #0000ff;">Refresh</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br /><br />&nbsp; &nbsp;<span style="color: #0000ff;">REDEFINE</span> <span style="color: #0000ff;">BUTTON</span> oBtn5 <span style="color: #0000ff;">ID</span> <span style="color: #000000;">715</span> <span style="color: #0000ff;">OF</span> oDlg ;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000ff;">ACTION</span><span style="color: #000000;">&#40;</span> oBrowse:<span style="color: #000000;">Report</span><span style="color: #000000;">&#40;</span><span style="color: #ff0000;">"Apuntes´s list"</span><span style="color: #000000;">&#41;</span>, oBrowse:<span style="color: #0000ff;">Refresh</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br /><br />&nbsp; &nbsp;<span style="color: #0000ff;">REDEFINE</span> <span style="color: #0000ff;">BUTTON</span> oBtn6 <span style="color: #0000ff;">ID</span> <span style="color: #000000;">716</span> <span style="color: #0000ff;">OF</span> oDlg <span style="color: #0000ff;">ACTION</span><span style="color: #000000;">&#40;</span> oDlg:<span style="color: #000000;">End</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br /><br /><br /><br /><br /><br /><br />&nbsp; &nbsp;<span style="color: #0000ff;">ACTIVATE</span> <span style="color: #0000ff;">DIALOG</span> oDlg <span style="color: #0000ff;">CENTERED</span> <span style="color: #0000ff;">ON</span> <span style="color: #0000ff;">INIT</span> oBrowse:<span style="color: #000000;">SetFocus</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br /><br /><br />&nbsp; &nbsp;ado_CierraRecordSet<span style="color: #000000;">&#40;</span> @oRs <span style="color: #000000;">&#41;</span><br /><br /><br /><br /><br /><br /><span style="color: #00C800;">RETURN</span> <span style="color: #00C800;">NIL</span><br /><span style="color: #B900B9;">// ---------------------------------------------------------------------------</span><br /><br /><br /><span style="color: #B900B9;">// ---------------------------------------------------------------------------</span><br /><span style="color: #B900B9;">// Función ....: AltasApuntes</span><br /><span style="color: #B900B9;">// Descripción : A¤adimos un registro a la base de datos.</span><br /><span style="color: #B900B9;">// Variables ..: lLogico -> valor l¢gico, para no duplicar c¢digos.</span><br /><span style="color: #B900B9;">// &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; nCodigo -> para comprobar c¢digos mediante b£squeda.</span><br /><span style="color: #B900B9;">// Notas ......: Comprobamos que el c¢digo introducido sea uno de nuevo.</span><br /><span style="color: #B900B9;">// ---------------------------------------------------------------------------</span><br /><span style="color: #00C800;">FUNCTION</span> AltasApuntes<span style="color: #000000;">&#40;</span> lAppend, nRegistro <span style="color: #000000;">&#41;</span><br /><br />&nbsp; &nbsp;<span style="color: #00C800;">LOCAL</span> oDlg &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #B900B9;">// Objeto Diálogo</span><br />&nbsp; &nbsp;<span style="color: #00C800;">LOCAL</span> oRs, oData, oError<br />&nbsp; &nbsp;<span style="color: #00C800;">LOCAL</span> lSave &nbsp; &nbsp; &nbsp; := .F. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #B900B9;">// Grabado</span><br /><br /><br />&nbsp; &nbsp;<span style="color: #00C800;">DEFAULT</span> lAppend &nbsp;:= .F. &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #B900B9;">// Añadir</span><br /><br /><br /><br /><br /><br /><br />&nbsp; &nbsp;<span style="color: #B900B9;">//</span><br />&nbsp; &nbsp;<span style="color: #B900B9;">// Seleccionamos RecordSet</span><br />&nbsp; &nbsp;<span style="color: #B900B9;">//-------------------------</span><br />&nbsp; &nbsp;oRs &nbsp; := ado_AbreRecordSet<span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">"select * from APUNTES order by FECHA ASC"</span> &nbsp;<span style="color: #000000;">&#41;</span><br /><br />&nbsp; &nbsp;<span style="color: #00C800;">IF</span> oRs = <span style="color: #00C800;">nil</span><br />&nbsp; &nbsp; &nbsp; <span style="color: #00C800;">RETURN</span> <span style="color: #00C800;">NIL</span><br />&nbsp; &nbsp;<span style="color: #00C800;">ENDIF</span><br /><br /><br /><br /><br /><br />&nbsp; &nbsp;<span style="color: #00C800;">IF</span> lAppend &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #B900B9;">// Si hay que añadir</span><br />&nbsp; &nbsp; &nbsp; oData := TDataRow<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>:<span style="color: #00C800;">New</span><span style="color: #000000;">&#40;</span> oRs, <span style="color: #00C800;">nil</span>, .t. <span style="color: #000000;">&#41;</span><br /><br />&nbsp; &nbsp; &nbsp; oData:<span style="color: #000000;">Fecha</span> &nbsp; &nbsp;:= Date<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp; &nbsp; oData:<span style="color: #000000;">Apunte</span> &nbsp; := <span style="color: #ff0000;">"test sample in SUNDAY "</span>+cvalToChar<span style="color: #000000;">&#40;</span>datetime<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp; &nbsp; oData:<span style="color: #000000;">nIngreso</span> := nrandom<span style="color: #000000;">&#40;</span><span style="color: #000000;">10</span><span style="color: #000000;">&#41;</span><br /><br />&nbsp; &nbsp;<span style="color: #00C800;">ENDIF</span><br /><br /><br />&nbsp; &nbsp;oData:<span style="color: #000000;">Save</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br /><br /><br />&nbsp; &nbsp;alert<span style="color: #000000;">&#40;</span><span style="color: #ff0000;">"added new record"</span>+CRLF+CRLF+oData:<span style="color: #000000;">Apunte</span><span style="color: #000000;">&#41;</span><br /><br /><br /><br /><br />&nbsp; &nbsp;ado_CierraRecordSet<span style="color: #000000;">&#40;</span> @oRs <span style="color: #000000;">&#41;</span><br /><br /><br /><br /><span style="color: #00C800;">RETURN</span> <span style="color: #00C800;">NIL</span><br /><span style="color: #B900B9;">// ---------------------------------------------------------------------------</span><br /><br /><br /><br /><br /><br /><br /><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><span style="color: #00C800;">FUNCTION</span> ado_String<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><br />&nbsp;<span style="color: #00C800;">LOCAL</span> cMotor := <span style="color: #ff0000;">"MSACCESS"</span><br /><br />&nbsp;<span style="color: #00C800;">LOCAL</span> cBD &nbsp; &nbsp;:= HB_DIRBASE<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>+<span style="color: #ff0000;">"ACCESS.MDB"</span><br /><br /><br /><br />&nbsp;<span style="color: #00C800;">DO</span> <span style="color: #00C800;">CASE</span><br />&nbsp; &nbsp; <span style="color: #00C800;">CASE</span> cMotor == <span style="color: #ff0000;">"MSACCESS"</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cStr &nbsp;:= <span style="color: #ff0000;">'Provider='</span>+<span style="color: #ff0000;">"Microsoft.Jet.OLEDB.4.0"</span>+<span style="color: #ff0000;">';Data Source='</span>+cBD<br /><br /><br />&nbsp; &nbsp; <span style="color: #00C800;">CASE</span> cMotor == <span style="color: #ff0000;">"MYSQL"</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cStr &nbsp;:= <span style="color: #ff0000;">"Driver={MySQL ODBC 3.51 Driver};Server=dolphintest.sitasoft.net;"</span> + ;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff0000;">"Database=dolphin_man;User=test_dolphin;Password=123456;Option=3;"</span><br /><br /><br />&nbsp;<span style="color: #00C800;">ENDCASE</span><br /><br /><br /><br /><span style="color: #00C800;">RETURN</span> cStr<br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><br /><br /><br /><br /><br /><br /><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><span style="color: #B900B9;">//</span><br /><span style="color: #B900B9;">// FUNCIONES PARA EL MANEJO DE RECORDSET</span><br /><span style="color: #B900B9;">// -------------------------------------</span><br /><span style="color: #B900B9;">//</span><br /><span style="color: #B900B9;">//</span><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><span style="color: #00C800;">FUNCTION</span> ado_AbreRecordSet<span style="color: #000000;">&#40;</span> cSQL <span style="color: #000000;">&#41;</span><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><br />&nbsp; &nbsp; <span style="color: #00C800;">LOCAL</span> oError<br /><br />&nbsp; &nbsp; <span style="color: #00C800;">DEFAULT</span> cSQL := <span style="color: #ff0000;">"SELECT * From TablaInexistente"</span><br /><br /><br /><br />&nbsp; &nbsp; <span style="color: #B900B9;">// open a recordset on demand with sql statement and connection string</span><br />&nbsp; &nbsp; oRsUser := TOleAuto<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>:<span style="color: #00C800;">New</span><span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">"ADODB.Recordset"</span> <span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp; oRsUser:<span style="color: #000000;">CursorType</span> &nbsp; &nbsp; := <span style="color: #000000;">1</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #B900B9;">// opendkeyset</span><br />&nbsp; &nbsp; oRsUser:<span style="color: #000000;">CursorLocation</span> := <span style="color: #000000;">3</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #B900B9;">// local cache</span><br />&nbsp; &nbsp; oRsUser:<span style="color: #000000;">LockType</span> &nbsp; &nbsp; &nbsp; := <span style="color: #000000;">3</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #B900B9;">// lockoportunistic</span><br /><br /><br />&nbsp; &nbsp; <span style="color: #00C800;">TRY</span><br />&nbsp; &nbsp; &nbsp; oRsUser:<span style="color: #000000;">Open</span><span style="color: #000000;">&#40;</span> cSQL, cStr <span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp; &nbsp; oCn &nbsp; &nbsp;:= oRsUser:<span style="color: #000000;">ActiveConnection</span><br />&nbsp; &nbsp; &nbsp; oRdbms := FW_RDBMSName<span style="color: #000000;">&#40;</span> oCn <span style="color: #000000;">&#41;</span><br /><br />&nbsp; &nbsp; CATCH oError<br />&nbsp; &nbsp; &nbsp; ado_ErrorNoRecordSet<span style="color: #000000;">&#40;</span>oError<span style="color: #000000;">&#41;</span> &nbsp; <span style="color: #B900B9;">// Mensaje de Error</span><br />&nbsp; &nbsp; &nbsp; oRsUser := <span style="color: #00C800;">nil</span><br />&nbsp; &nbsp; END<br /><br /><br /><span style="color: #00C800;">RETURN</span> oRsUser<br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><br /><br /><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><span style="color: #00C800;">FUNCTION</span> ado_CierraRecordSet<span style="color: #000000;">&#40;</span> oRs <span style="color: #000000;">&#41;</span><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br />&nbsp; &nbsp; <span style="color: #00C800;">local</span> oErr<br /><br /><br />&nbsp; &nbsp; <span style="color: #00C800;">TRY</span><br />&nbsp; &nbsp; &nbsp; &nbsp;oRs:<span style="color: #000000;">Close</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp;oRs := <span style="color: #00C800;">Nil</span><br />&nbsp; &nbsp; CATCH oErr<br />&nbsp; &nbsp; &nbsp; &nbsp;ado_ErrorNoRecordSet<span style="color: #000000;">&#40;</span>oErr<span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp; END<br /><br /><br /><br />&nbsp; &nbsp; oRs := <span style="color: #00C800;">Nil</span><br /><br /><br /><span style="color: #00C800;">RETURN</span> <span style="color: #00C800;">NIL</span><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><br /><br /><br /><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><span style="color: #00C800;">FUNCTION</span> ado_Borrar<span style="color: #000000;">&#40;</span> oRs <span style="color: #000000;">&#41;</span><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br />&nbsp; &nbsp; <span style="color: #00C800;">LOCAL</span> n<br />&nbsp; &nbsp; <span style="color: #00C800;">LOCAL</span> oErr1, oErr2, oErr3<br /><br /><br /><br />&nbsp; &nbsp; <span style="color: #00C800;">if</span> MsgYesNo<span style="color: #000000;">&#40;</span> <span style="color: #ff0000;">"¿ Desea BORRAR este Registro ?."</span>+CRLF+CRLF+<span style="color: #ff0000;">"Si tiene dudas, seleccione No."</span>, <span style="color: #ff0000;">" B O R R A R &nbsp; R E G I S T R O"</span> <span style="color: #000000;">&#41;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00C800;">if</span> oRs:<span style="color: #000000;">RecordCount</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> = <span style="color: #000000;">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MsgAlert<span style="color: #000000;">&#40;</span><span style="color: #ff0000;">"ERROR: No hay ningún registro en la tabla."</span>+CRLF+CRLF+<span style="color: #ff0000;">"No hay nada que BORRAR."</span>, <span style="color: #ff0000;">" E R R O R "</span><span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00C800;">RETURN</span> <span style="color: #00C800;">NIL</span><br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00C800;">endif</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp;n := oRs:<span style="color: #000000;">AbsolutePosition</span><br /><br /><br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00C800;">try</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; oRs:<span style="color: #000000;">Delete</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp;catch oErr1<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MsgStop<span style="color: #000000;">&#40;</span><span style="color: #ff0000;">"ERROR: No se ha podido ejecutar la operación de borrado."</span>+CRLF+CRLF+oErr1:<span style="color: #000000;">Description</span>, <span style="color: #ff0000;">" E R R O R "</span><span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00C800;">return</span><span style="color: #000000;">&#40;</span>.f.<span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp;end<br /><br /><br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #B900B9;">///oRs:Update()</span><br /><br /><br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00C800;">If</span> !oRs:<span style="color: #000000;">RecordCount</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> = <span style="color: #000000;">0</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; oRs:<span style="color: #000000;">AbsolutePosition</span> := <span style="color: #0000ff;">Min</span><span style="color: #000000;">&#40;</span> n, oRs:<span style="color: #000000;">RecordCount</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00C800;">endif</span><br /><br /><br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">MsgInfo</span><span style="color: #000000;">&#40;</span><span style="color: #ff0000;">"El Registro ha sido BORRADO correctamente."</span>, <span style="color: #ff0000;">" A V I S O "</span><span style="color: #000000;">&#41;</span><br /><br /><br />&nbsp; &nbsp; <span style="color: #00C800;">else</span><br />&nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #0000ff;">MsgInfo</span><span style="color: #000000;">&#40;</span><span style="color: #ff0000;">"El USUARIO ha cancelado la operación de Borrar."</span>, <span style="color: #ff0000;">" A V I S O "</span><span style="color: #000000;">&#41;</span><br /><br />&nbsp; &nbsp; <span style="color: #00C800;">endif</span><br /><br /><br /><br /><span style="color: #00C800;">RETURN</span> <span style="color: #00C800;">NIL</span><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><br /><br /><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><span style="color: #00C800;">FUNCTION</span> ado_ErrorNoRecordSet<span style="color: #000000;">&#40;</span>oErr<span style="color: #000000;">&#41;</span><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><br />&nbsp; &nbsp;<span style="color: #B900B9;">//local nErr, oErr, cErr</span><br />&nbsp; &nbsp;<span style="color: #00C800;">local</span> cErr<br />&nbsp; &nbsp;<span style="color: #00C800;">local</span> oConexion &nbsp; &nbsp;:= oCn<br />&nbsp; &nbsp;<span style="color: #00C800;">local</span> cInstruccion := <span style="color: #ff0000;">""</span> <span style="color: #B900B9;">//oErr:Args[1]</span><br /><br /><br />&nbsp; &nbsp;<span style="color: #B900B9;">//</span><br />&nbsp; &nbsp;<span style="color: #B900B9;">// fix oErr:Args[1], a veces está vacío</span><br />&nbsp; &nbsp;<span style="color: #B900B9;">//--------------------------------------</span><br />&nbsp; &nbsp;<span style="color: #00C800;">if</span> HB_IsNil<span style="color: #000000;">&#40;</span> oErr:<span style="color: #000000;">Args</span> <span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp; &nbsp; cInstruccion := space<span style="color: #000000;">&#40;</span><span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp;<span style="color: #00C800;">else</span><br />&nbsp; &nbsp; &nbsp; cInstruccion := oErr:<span style="color: #000000;">Args</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">1</span><span style="color: #000000;">&#93;</span><br />&nbsp; &nbsp;<span style="color: #00C800;">endif</span><br /><br /><br /><br />&nbsp; &nbsp;<span style="color: #B900B9;">//if ( nErr := oConexion:Errors:Count ) > 0</span><br />&nbsp; &nbsp;<span style="color: #B900B9;">// &nbsp; oErr &nbsp;:= oConexion:Errors( nErr - 1 )</span><br />&nbsp; &nbsp; &nbsp; WITH OBJECT oErr<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cErr &nbsp; &nbsp; := <span style="color: #ff0000;">"No se puede ejecutar la instrucción "</span> + cValToChar<span style="color: #000000;">&#40;</span> cInstruccion <span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cErr &nbsp; &nbsp; += CRLF+CRLF+oErr:<span style="color: #000000;">Description</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cErr &nbsp; &nbsp; += CRLF+CRLF + <span style="color: #ff0000;">'Operación : '</span> + cValToChar<span style="color: #000000;">&#40;</span> oErr:<span style="color: #000000;">Operation</span> <span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;cErr &nbsp; &nbsp; += CRLF+CRLF + <span style="color: #ff0000;">'Fuente del Error : '</span> + cValToChar<span style="color: #000000;">&#40;</span> oErr:<span style="color: #000000;">Filename</span> <span style="color: #000000;">&#41;</span><br /><br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;MsgAlert<span style="color: #000000;">&#40;</span> cErr, <span style="color: #ff0000;">"ADO ERROR RecordSet"</span> <span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp; &nbsp; END<br />&nbsp; &nbsp;<span style="color: #B900B9;">//else</span><br />&nbsp; &nbsp;<span style="color: #B900B9;">// &nbsp; MsgAlert( "ADO ERROR desconocido." )</span><br />&nbsp; &nbsp;<span style="color: #B900B9;">//endif</span><br /><br /><br /><span style="color: #00C800;">RETURN</span> <span style="color: #00C800;">NIL</span><br /><span style="color: #B900B9;">//----------------------------------------------------------------------------//</span><br /><br /><br /><br /><br />*-------------------------------------------------------------------------------<br /><span style="color: #00C800;">FUNCTION</span> ADO_RecCount<span style="color: #000000;">&#40;</span>oRs<span style="color: #000000;">&#41;</span><br />*-------------------------------------------------------------------------------<br /><br />&nbsp; &nbsp;<span style="color: #00C800;">local</span> nRecord := <span style="color: #000000;">0</span><br /><br />&nbsp; &nbsp;nRecord := oRs:<span style="color: #000000;">AbsolutePosition</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp;nRecord := iif<span style="color: #000000;">&#40;</span>nRecord=<span style="color: #00C800;">nil</span>,<span style="color: #000000;">-1</span>,nRecord<span style="color: #000000;">&#41;</span><br /><br />&nbsp; &nbsp;<span style="color: #00C800;">if</span> nRecord < <span style="color: #000000;">1</span><br />&nbsp; &nbsp; &nbsp; <span style="color: #00C800;">return</span> <span style="color: #000000;">0</span><br />&nbsp; &nbsp;<span style="color: #00C800;">else</span><br />&nbsp; &nbsp; &nbsp; <span style="color: #00C800;">return</span> oRs:<span style="color: #000000;">RecordCount</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><br />&nbsp; &nbsp;<span style="color: #00C800;">endif</span><br /><br /><span style="color: #00C800;">return</span> <span style="color: #000000;">0</span><br />*-------------------------------------------------------------------------------<br /><br /><br /><br />&nbsp;</div>[/code:1q01ldrs] .rc file: [code=fw:1q01ldrs]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #00D7D7;">#include</span> <windows.h><br /><span style="color: #00D7D7;">#include</span> <commctrl.h><br /><br /><br /><br />APUNTES <span style="color: #0000ff;">DIALOG</span> <span style="color: #000000;">-3</span>, <span style="color: #000000;">1</span>, <span style="color: #000000;">516</span>, <span style="color: #000000;">289</span><br /><span style="color: #0000ff;">STYLE</span> 0x4L <br />CAPTION <span style="color: #ff0000;">"BROWSE"</span><br /><span style="color: #0000ff;">FONT</span> <span style="color: #000000;">8</span>, <span style="color: #ff0000;">"MS Sans Serif"</span><br /><span style="color: #000000;">&#123;</span><br />&nbsp;PUSHBUTTON <span style="color: #ff0000;">"&Añadir"</span>, <span style="color: #000000;">711</span>, <span style="color: #000000;">30</span>, <span style="color: #000000;">260</span>, <span style="color: #000000;">54</span>, <span style="color: #000000;">14</span><br />&nbsp;PUSHBUTTON <span style="color: #ff0000;">"&Borrar"</span>, <span style="color: #000000;">712</span>, <span style="color: #000000;">92</span>, <span style="color: #000000;">260</span>, <span style="color: #000000;">54</span>, <span style="color: #000000;">14</span><br />&nbsp;PUSHBUTTON <span style="color: #ff0000;">"&Modificar"</span>, <span style="color: #000000;">713</span>, <span style="color: #000000;">154</span>, <span style="color: #000000;">260</span>, <span style="color: #000000;">54</span>, <span style="color: #000000;">14</span><br />&nbsp;PUSHBUTTON <span style="color: #ff0000;">"&Filtrar"</span>, <span style="color: #000000;">714</span>, <span style="color: #000000;">216</span>, <span style="color: #000000;">260</span>, <span style="color: #000000;">54</span>, <span style="color: #000000;">14</span><br />&nbsp;PUSHBUTTON <span style="color: #ff0000;">"&Imprimir"</span>, <span style="color: #000000;">715</span>, <span style="color: #000000;">278</span>, <span style="color: #000000;">260</span>, <span style="color: #000000;">54</span>, <span style="color: #000000;">14</span><br />&nbsp;PUSHBUTTON <span style="color: #ff0000;">"&Salir"</span>, <span style="color: #000000;">716</span>, <span style="color: #000000;">444</span>, <span style="color: #000000;">260</span>, <span style="color: #000000;">54</span>, <span style="color: #000000;">14</span><br />&nbsp;CONTROL <span style="color: #ff0000;">""</span>, <span style="color: #000000;">101</span>, <span style="color: #ff0000;">"TXBrowse"</span>, <span style="color: #000000;">0</span> | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP, <span style="color: #000000;">18</span>, <span style="color: #000000;">18</span>, <span style="color: #000000;">480</span>, <span style="color: #000000;">228</span><br /><span style="color: #000000;">&#125;</span><br /><br /><br />&nbsp;</div>[/code:1q01ldrs]
ADO question: Access is not refresing properly
Lucas, [quote="lucasdebeltran":1qqyawcl]Just click on Añadir, and you will see that oRs is not updated:[/quote:1qqyawcl] Try using adOpenDynamic: [url:1qqyawcl]http&#58;//www&#46;w3schools&#46;com/ado/met_rs_open&#46;asp[/url:1qqyawcl] EMG
ADO question: Access is not refresing properly
Lucas You define oRs as your recordset for your xBrowse .. when you create a record .. pass oRs, and oBrowse to your add routine and DO NOT redefine oRs as local in that add routine. oRs Represents the data that can be passed as a parameter .. in your add routine just oRs:AddNew() ( modify your fields ) .. and oRs:Update() then oBrowse:ReFresh() .. oRs:ReQuery() is only helpful when you have a COMPLEX join in your recordset and adding or deleting a record to that complex oRs will cause un-intended consequences to those joined tables. IN that situation .. you can create a new recordset .. add your record and then oRs:Requery() the original recordset to make your new row visible. Rick Lipkin
ADO question: Access is not refresing properly
Enrico, Thank you, I am going to test it. Rick, I need to have an independant oRs in Add function -Añadir()-, as the add function can also be called out of the xBrowse. So the strange think is that, despite the two Recordsets, Access do not refresh them sometimes at instant. Have you tested my sample?. Thank you. best regards
ADO question: Access is not refresing properly
[quote:1yakhzd4]Try using adOpenDynamic: <!-- m --><a class="postlink" href="http://www.w3schools.com/ado/met_rs_open.asp">http://www.w3schools.com/ado/met_rs_open.asp</a><!-- m --> EMG[/quote:1yakhzd4] No effect, the same problem . Thanks.
ADO question: Access is not refresing properly
Lucas, [quote="lucasdebeltran":3q1xlofc][quote:3q1xlofc]Try using adOpenDynamic: <!-- m --><a class="postlink" href="http://www.w3schools.com/ado/met_rs_open.asp">http://www.w3schools.com/ado/met_rs_open.asp</a><!-- m --> EMG[/quote:3q1xlofc] No effect, the same problem . Thanks.[/quote:3q1xlofc] Did you read the article? This is expected behavior for adOpenKeySet: [quote:3q1xlofc]you can't see records that other users add[/quote:3q1xlofc] EMG
ADO question: Access is not refresing properly
Yes, I did and I tested it with no luck. But when you add another record, the second, I see both after oRs:Requery(). With other RDDS I don´t have this problem. Quite strange.
ADO question: Access is not refresing properly
Mr Lucas I am sending you a sample program to your personal e-mail. This is a modified version of the program you sent me. ReQuery is working perfectly here for me. Please test it at your end and let me know the results.
ADO record fantasma
cuando esta la tabla vacia ado marca error , sera que ado no maneja el record fantasma como se le llama. saludos. fernando sandoval ruiz
ADO record fantasma
Que yo sepa, las tablas SQL no tienen "registro fantasma" como los DBFs, si en un EXECUTE() de ADO no te regresa ningun dato, es simplemente que la tabla esta vacia
ADO record fantasma
Fernando, [quote:2402dxpz]cuando esta la tabla vacia ado marca error , sera que ado no maneja el record fantasma como se le llama.[/quote:2402dxpz] ADO te marcará siempre error cuando intentas hacer alguna operación y en esa operación no hay registro activo. Como buena costumbre, verifica si hay registros de dos maneras: con la propiedad recordcount y mirando si oRs:BOF() .AND. oRs:EOF() se cumple. Saludos, José Luis Capel
ADO record fantasma
Gracias, me lo sospeche, pero bueno hay trucos para bricar estas cosas. saludos. fernando sandoval ruiz
ADO record locking experiences
I would like to start a thread to discuss the way you manage record locking using ADO. My question is simple: Lets say that you have a record, and that you need to edit it and meanwhile you edit it, other users should not be able to edit it. How are you managing this situation ? I appreciate your comments
ADO record locking experiences
Antonio, I have created a table 'FILELOCK' in my SQL table, with a field 'table','table_id','user','pcname'. When I want to lock a record, I write te table,record-ID, user and PC-name to that table. (I created a function SQLLock) An other user that want to open the record check with a function SQLlock that the record is available. If not, it returns FALSE, otherwhise is locks the record by writing the info to the table FILELOCK. I use the info USER and PCNAME, so I can display the purson who have locked the record... So my function SQLlock works the same as rlock() If I want to unlock the record, I delete the record in FILELOCK.
ADO record locking experiences
Antonio I use a numeric signature file in the table that gets incremented +1 each time I save a record... user one fetches a record that has a current value ( lets say ) 1 and before I UpDate() that record, I have a function that opens a new recordset just on the rows primary key ( or rowid ) and the Signature field to check its value. If the Value is the same, I know no one has modified the record before I did. If the value has changed, then I know my edit has become 'stale' and someone has modified the same record before I did, in which case I cancel the Edit with a message like "Sorry .. someone has modified the record you are trying to change".... Rick Lipkin ps .. this assumes you buffer all your fields to memory values when you first read a record.
ADO record locking experiences
Marc, Rick, And how do you control if a user gets disconnected without releasing the locked record (using any of your techniques) ? In that situation the record would appear as locked but in fact nobody is locking it anymore...
ADO record locking experiences
Antonio I do not look for a lock .. whom ever gets to update the record first gets the Signature field+1 Update(). Then if workstation two tries to update the same record .. Within the Update() routine, I create a new recordset on the unique rowid ( primary key ) and see if the signature field matches .. if it doesn't .. I stop workstation 2 from Update() forcing them to cancel their edit and try again. In the case of a disconnect .. that record never got it signature field updated+1 so when workstation 2 tries to update .. the signature field matches and WS two gets the update. If WS 1 comes back online .. more than likely they would have had to re-boot and would have to go back into the program afterward WS 2 made their changes. Hope you understand my logic ? Rick Lipkin
ADO record locking experiences
[quote="Antonio Linares":14grxcav]Marc, Rick, And how do you control if a user gets disconnected without releasing the locked record (using any of your techniques) ? In that situation the record would appear as locked but in fact nobody is locking it anymore...[/quote:14grxcav] Antonio, If someone start the program, the program removes first all locks of that PC. The records are indeed locked if the program have crashed. After restarting the program, all locks are removed. At the moment, I'm modifiying my function, so it look for all users that are connected with the database. The Recordset-command that I use now is [code=fw:14grxcav]<div class="fw" id="{CB}" style="font-family: monospace;"><span style="color: #0000ff;">SELECT</span> SUBSTRING_INDEX<span style="color: #000000;">&#40;</span>host, <span style="color: #ff0000;">':'</span>, <span style="color: #000000;">1</span><span style="color: #000000;">&#41;</span> AS host_short <span style="color: #0000ff;">FROM</span>   information_schema.processlist <span style="color: #0000ff;">WHERE</span> db = <span style="color: #ff0000;">"MyProgram"</span> GROUP  BY host_short ORDER  BY host_short</div>[/code:14grxcav] Then I get a list af all connections. I will let you know the result...
ADO record locking experiences
Marc, But if u dont reconect then register to continue lock, or if u reconnect with another pc its the same... Good thread
ADO record locking experiences
[quote="Carles":1qp0h4f5]Marc, But if u dont reconect then register to continue lock, or if u reconnect with another pc its the same... Good thread[/quote:1qp0h4f5] Charles, That's the reason why I'm modifying my function. If I want to lock a record that is locked by someone else, I will run the query that check if the user is still connected, and then delete the records if it is disconnected..
ADO record locking experiences
Marc, Now i'm undertsand the process. Exist this table in all rdbm ?
ADO record locking experiences
Antonio, [quote="Antonio Linares":36q6evsr]I would like to start a thread to discuss the way you manage record locking using ADO. My question is simple: Lets say that you have a record, and that you need to edit it and meanwhile you edit it, other users should not be able to edit it. How are you managing this situation ? I appreciate your comments[/quote:36q6evsr] You have to use pessimistic locking and error trapping. This is the way ADO works. EMG
ADO record locking experiences
Enrico, Could you post an example ? thanks
ADO record locking experiences
Antonio, please look at LockType property: [url:1lnw53nd]http&#58;//www&#46;w3schools&#46;com/ado/prop_rs_locktype&#46;asp[/url:1lnw53nd] If you set it to adLockPessimistic, the second user trying to assign a value to the record, before the first one have called update method, will get a runtime error. With adLockOptimistic the lock is only on update call. You can use one of the two modes. Or you can lost yourself among the many DIY solutions. <!-- s:-) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":-)" title="Smile" /><!-- s:-) --> EMG
ADO sqloledb conection problem
To All I have a wierd situation where I have a very successful ADO xHarbour\FWH application ( executable ) which resides on a Win2003 server. When the users run the executable from the server ( shortcut on their pc ) the application connects to the off site SQL server and runs flawlessly. However .. if you are at the server console ( physically at the server ) .. and you run the same application ( on the server ) it will start but fail to connect to the first table. Totally exhausted here trying to find an answer .. I have found Google ideas on adding Persistant Security Info=False to no avail. Here is the connection string : oRs := TOleAuto():New( "ADODB.Recordset" ) oRs:CursorType := 1 // opendkeyset oRs:CursorLocation := 3 // local cache oRs:LockType := 3 // lockoportunistic cSQL := "SELECT * FROM utility WHERE progid ='"+xPROGID+"'" TRY oRS:Open(cSQL,'Provider='+xPROVIDER+';Data Source='+xSOURCE+';Initial Catalog='+xCATALOG+';User Id='+xUSERID+';Password='+xPASSWORD ) CATCH oErr MsgInfo( "Error in Opening UTILITY CRASH BURN table" ) /// dies here RETURN NIL END TRY Again .. this app runs the executable flawlessly as a shortcut on the workstation .. but the same app will not run sitting at the server running the app ON the server ?? It seems to me that the Server is breaking the connection string and I just don't know what to change or to try as far as 'trusted sites' perhaps or some other Win2003 process that is keeping this app from connecting to the off site Sql Server. Hope that makes sense. Any help would be appreciated. Rick Lipkin SC Dept of Health, USA
ADO sqloledb conection problem
Rick: Just an idea that came into me actually. I think It could be the SQL Sever configurarion, I dunno if there's a parameter that let you allow the configuracion from the server. In other database I've used before, you have to grant acces to the SYSTEM user in order to be able to connect from the console of the server instead from a workstation. Just an idea.
ADO sqloledb conection problem
Rene I am thinking along the same lines .. here is the actual example .. we have a 2003 server as a Citrix remote access box .. the server acts like a workstation and logs into a Novell server that has the executable in question. When you click on the short-cut the application noticibly starts .. but when the execution hits the first connection string .. it times out. I decided to take Novell out of the picture and just take a pure 2003 server and put the ADO app on a share .. connecting to the share with a unc .. from my workstation .. the application runs flawlessly... Now, go to the server and drill to the share and the app and try to run it .. and that is where it breaks. There is a a definite Server 2003 process that is intefearing with the ADO connection to the SQL server .. which is off site by the way. So I am really looking for a silver bullet that will allow the application to run from the server console. We have over 5000 people in the Agency and this application is the Time and Reporting system.. Many of the folks tele-commute and access the program from Citrix .. thus bringing this problem to the forefront. There has to be something in the Server that is breaking the connection .. just don't know what .. Rick Lipkin
ADO sqloledb conection problem
To All This has been fixed .. turned out to be a DNS problem on the Win2003 servers .. Thanks Rick Lipkin
ADO string de conexion SQL Server 2008 ?
Buen dia para todos, Estoy usando ADO para trabajar con SQL Server 2008. Estoy intentando conectarme con SQL server 2008 desde un equipo a el Servidor SQL Server 2008 sin lograrlo. En modo local me funciona el siguiente string de conexion (si me conecta) : Provider=SQLNCLI10;Server=myServerAddress;Database=myDataBase;Trusted_Connection=yes; Pero en modo remoto no funciona (es decir probando desde otro equipo) La conexion a el servidor SQL lo tengo como autenticacion de windows (por defecto). Que string debo usar para la conexion remota ? Que debo configurar en el servidor SQL 2008 para que me de conexion remota ? Desde ya muchas gracias, Saludos Cordiales.
ADO string de conexion SQL Server 2008 ?
Hola, yo lo hice asi : cString:= "Provider=SQLOLEDB;server="+cServer+";database="+cDataBase+";uid="+cUser+";pwd="+cPass oCnx:=TAdoConn():New( adUseServer ) if !oCnx:Open(xConnStr) msginfo( 'String: ' + xConnStr + CRLF +; 'No hay conexión con el Servidor...') RETURN NIL else msginfo("Conectado") endif Espero te sirva... Salu2, Ariel.
ADO string de conexion SQL Server 2008 ?
Ariel, Gracias, voy a probarlo. Albeiro.
ADO update visability between workstations
To All I have completed a major SQL ADO application and am finding that workstation recordsets are not being updated as other workstations make changes. I am caching the recordsets to the local client .. In looking on MSDN I see a ReSync method ?? has anyone used this to just resync a specific record in a recodset ?? The documentation seems to support the single table record refresh .. I would think the syntax would be : oRs:ReSync() Issue that and the object record will be refreshed from the table and included in the client cache ?? Rick Lipkin SC Dept of Health, USA cSQL := "SELECT * FROM CERT order by reg_no" 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 CERT table" ) oDlg:End() RETURN(.F.) END TRY
ADO update visability between workstations
Rick: Your cursor type is wrong, you must use adOpenDynamic (2) in order to see changes others make in the recordset. However not all the databases support the dynamic update of the recordset.
ADO update visability between workstations
Rene According to the doccumentation I found : (1)adOpenKeyset: A static snap-shot of the primary key values of the records that match your search criteria are put into the recordset. As you scroll backwards and forwards, the primary key value in the recordset is used to fetch the current data for that record from the database. This cursor thus allows you to see updates to the data made by other users, but it doesn't let you see new records that have been added by other users (because the primary key values for those records are not in your recordset). (2)adOpenDynamic: A dynamic snapshot of the database is maintained by OLEDB/ADO. All changes by other users to the underlying database are visible. Obviously this is the most sophisticated cursor, and thus is usually the most expensive. Because the data in the recordset is dynamic, attributes like AbsolutePosition and AbsolutePage can not be set. The adOpenDynamic cursor is not supported by the Jet OLEDB Provider. AbsolutePosition I need for the skipper in the listbox .. that is why I chose OpenKeyset .. I have not tried OpenDynamic .. I can easily try it .. I did find a Resync method which seems to be my answer ... I am in 'un-charted' territory .. just curious if you have used Resync() .. and what the syntax would look like ?? oRs:ReSync() ?? when I open a record to view or edit ?? Rick Lipkin oRs := TOleAuto():New( "ADODB.Recordset" ) oRs:CursorType := 1 // opendkeyset oRs:CursorLocation := 3 // local cache oRs:LockType := 3 // lockoportunistic cSQL := "SELECT * FROM USERINFO order by USERID" TRY oRs:Open( cSQL,'Provider='+xPROVIDER+';Data Source='+xSOURCE+';Initial Catalog='+xCATALOG+';User Id='+xUSERID+';Password='+xPASSWORD ) CATCH oErr MsgInfo( "Error in Opening USERINFO table" ) RETURN(.F.) END TRY oRs:Find("USERID = '"+xLOGIN+"'" ) IF oRs:eof oRs:MoveFirst() ENDIF DEFINE WINDOW oUser ; FROM 2,2 to 25,65 ; of oWndMDI ; TITLE "USERINFO Records Browse" ; MENU BuildMenu(oRs) ; NOMINIMIZE ; NOZOOM ; MDICHILD @ 0, 0 LISTBOX oBrow FIELDS ; oRs:Fields("USERID"):Value, ; oRs:Fields("READ"):Value, ; oRs:Fields("WRITE"):Value, ; oRs:Fields("INSP"):Value, ; oRs:Fields("SUPER"):Value, ; oRs:Fields("DISTRICT"):Value ; SIZES 90,60,60,60,60,100 ; HEADERS "Userid", ; "Read", ; "Write", ; "Insp", ; "Super", ; "Dist" ; ON DBLCLICK _userview( "V" ) ; of oUser ; UPDATE oBrow:bLogicLen := { || oRs:RecordCount } oBrow:bGoTop := { || oRs:MoveFirst() } oBrow:bGoBottom := { || oRs:MoveLast() } oBrow:bSkip := { | nSkip | Skipper( oRs, nSkip ) } oBrow:cAlias := "ARRAY" oUSER:oClient := oBROW oUSER:SetControl( oBROW ) ACTIVATE WINDOW oUser ; VALID ( IIF( !lOK, UserClose(.T., oRs), .F. )) RETURN( NIL ) //------------------------------- STATIC FUNCTION SKIPPER( oRsx, nSkip ) LOCAL nRec := oRsx:AbsolutePosition oRsx:Move( nSkip ) IF oRsx:EOF; oRsx:MoveLast(); ENDIF IF oRsx:BOF; oRsx:MoveFirst(); ENDIF RETURN( oRsx:AbsolutePosition - nRec ) //-------------------------
ADO update visability between workstations
Rene Changing the open dynamic did not seem to work .. the recordset opened and I had a top and bottom to my listbox .. however .. there was no visability of updates .. don't think SQL server supports dynamic and it just opened it like it was static. The Resync() option gave a run-time error unfortunitly .. I have implemented a signature field so I can stop a stale recordset from writing over updated records .. I may have to abandon the local caching of the recordset in favor of just pointing to the server .. going to take a hit in performance .. I may have to re-think how I am presenting the data to the users and force them to query a record each time for get a fresh recordset. Antonio .. I am using the same mechanism you are using in the ADO RDD with the same open methods .. have you tested multiple workstation visability ?? Rick Lipkin
ADO update visability between workstations
Rick, I want to thank you for sharing these valuable informations. EMG
ADO update visability between workstations
Only a test, but seems work: [code:29d4yjr4] oRs &#58;= CREATEOBJECT&#40; "ADODB&#46;Recordset" &#41; cSQL &#58;= "SELECT * FROM Articoli ORDER BY codice ASC" TRY oRs&#58;Open&#40; cSQL, oConnection, adOpenStatic, adLockOptimistic &#41; // 3, 3 CATCH oError MsgStop&#40;oError&#58;Operation+CRLF+oError&#58;Description,"Ado Connection"&#41; RETURN NIL END TRY DEFINE TIMER oTimer; INTERVAL 1000; ACTION &#40; nTimer++, IIF&#40; nTimer > 10, RefreshSQL&#40; @nTimer, oTimer, oRs, oBrw &#41;, "" &#41; &#41; OF oDlg ACTIVATE TIMER oTimer oTimer&#58;deActivate&#40;&#41; DEFINE DIALOG oDlg ; FROM 7,7 to 35,104 ; TITLE "Articoli" @ 0, 0 LISTBOX oBrw; FIELDS "", "", "", "", ""; HEADERS "Codice", "Descrizione", "Desc&#46; Aggiuntiva", "Nota 1", "Nota 2"; OF oDlg oBrw&#58;bLine &#58;= &#123; || &#123; oRs&#58;Fields&#40; "codice" &#41;&#58;Value, oRs&#58;Fields&#40; "descrizione" &#41;&#58;Value, oRs&#58;Fields&#40; "descrizione_aggiuntiva" &#41;&#58;Value, oRs&#58;Fields&#40; "nota1" &#41;&#58;Value, oRs&#58;Fields&#40; "nota2" &#41;&#58;Value &#125; &#125; oBrw&#58;bLogicLen &#58;= &#123; || oRs&#58;RecordCount &#125; oBrw&#58;bGoTop &#58;= &#123; || oRs&#58;MoveFirst&#40;&#41; &#125; oBrw&#58;bGoBottom &#58;= &#123; || oRs&#58;MoveLast&#40;&#41; &#125; oBrw&#58;bSkip &#58;= &#123; | nSkip | SkipperAdo&#40; oRs, nSkip &#41; &#125; oBrw&#58;cAlias &#58;= "" ACTIVATE DIALOG oDlg; ON INIT &#40; oDlg&#58;SetControl&#40; oBrw &#41;, nSecFine&#58;= SECONDS&#40;&#41;, InfStat&#40; NTRIM&#40; nSecFine-nSecIni &#41; + " secondi&#46;&#46;&#46; - " + NTRIM&#40; oRs&#58;RecordCount &#41; + " records&#46;&#46;&#46;" &#41;, oTimer&#58;activate&#40;&#41; &#41; oTimer&#58;end&#40;&#41; TRY oRs&#58;Close&#40;&#41; CATCH END TRY TRY oConnection&#58;Close&#40;&#41; CATCH END TRY RETURN NIL FUNCTION RefreshSQL&#40; nTimer, oTimer, oRs, oBrw &#41; LOCAL nRec &#58;= oRs&#58;AbsolutePosition nTimer &#58;= 0 oTimer&#58;deActivate&#40;&#41; CursorWait&#40;&#41; TRY oRs&#58;Requery&#40;&#41; CATCH END TRY TRY oRs&#58;Move&#40; nRec-1 &#41; CATCH END TRY oBrw&#58;refresh&#40;&#41; CursorArrow&#40;&#41; oTimer&#58;Activate&#40;&#41; RETURN NIL [/code:29d4yjr4]
ADO update visability between workstations
Rick, > Antonio .. I am using the same mechanism you are using in the ADO RDD with the same open methods .. have you tested multiple workstation visability ?? > No, sorry, we have just done local tests with it
ADO update visability between workstations
Pedro I did see the ReQuery method .. however I would prefer not to re-query a full recordset .. Have you tried the ReSync method ?? Any ideas the syntax ?? Rick Lipkin
ADO update visability between workstations
Resync for current record only: oRs:Resync( adAffectCurrent, adResyncAllValues ) There are times when Resync fails. (Discussion on this topic is too lengthy) Better put it in TRY CACH END construct and use ReQuery as alternative
ADO update visability between workstations
Rick, Resync method don't work to me. (in my tests allways fails, I'm a begginer with ADO) Requery seems to be fast (in a local net) Regards
ADO update visability between workstations
There was a discussion above to use adOpenDynamic or adOpenKeyset for opening a recordset. But when a recordset is opened on clientside (with cursorlocation as adUseClient) the provider ignores what we speicfy as CursorType (adOpenDynamic or Keyset), and returns a recordset with cursortype as adOpenStatic only. adOpenDynamic or adOpenKeyset cursortype is useful only for recorsets opened with cursor location adUseSever. Often this is not what we do.
ADO update visability between workstations
1 2 oRs:Resync( adAffectCurrent, adResyncAllValues ) Excellant .. that is what I was looking for .. I will definitly surround it with Try\Catch .. and I will report back my success .. adAffectCurrent = 1 adResyncAllValues = 2 I have tried the above and it fails each time .. does it matter if the data has changed or not ?? Rick Lipkin
ADO update visability between workstations
I work extensively with very large applications ADO and Oracle. My experience with MSSQL is limitted to smaller applications. Resync generally works even when the other users update the same row but occassionally fails. Better we keep in mind how Resync command internally works: RecordSet object has Properities collection. oRs:Properties("Resync Command"):Value is what ADO internally uses to retrieve the values of the current row. This value can be set by our program but i am not able to change this property through xharbour. (works in vbasic) ADO has to know the primary key or some unique id of the row to internally construct this command. For example a table has two columns "custid", "custname" with custid as primary key and if ado can know this, it will internelly construct the resync command as "select * from customers where custid = ?" and calls this command with custid as the parameter each time it refreshes. For oracle it uses rowid instead of primary key unless we configure ado differently. This has its own side effects. This should give you some idea about the limiations of Resync command. So we can use Resync, keeping in mind that it can fail at times and for some recordsets. Solution is to programitically assign right values to the two properties oRs:Properties("Root Table") and oRs:Properties("Resync Command")
ADO update visability between workstations
RecordSet object has Properities collection. oRs:Properties("Resync Command"):Value is what ADO internally uses to retrieve the values of the current row. This value can be set by our program but i am not able to change this property through xharbour. (works in vbasic) ADO has to know the primary key or some unique id of the row to internally construct this command. For example a table has two columns "custid", "custname" with custid as primary key and if ado can know this, it will internelly construct the resync command as "select * from customers where custid = ?" and calls this command with custid as the parameter each time it refreshes. For oracle it uses rowid instead of primary key unless we configure ado differently. This has its own side effects. Ok .. let me see here .. I have a table called CERT and a unique ID assigned to each row called EID Programatically, how would you assign the above properties for the Resync method to work ?? cEid := oRs:Fields("eid"):Value oRs:Properties("Resync Command"):Value := cEID oRs:ReSync( 1, 2 ) Rick Lipkin
ADO update visability between workstations
It should be like this. [code:xfhf3qbh] oRs&#58;Properties&#40;"Resync Command"&#41;&#58;Value &#58;= "SELECT * FROM CERT WHERE EID = ?" [/code:xfhf3qbh] But as I said earlier, assignment is not working through xHarbour. Please read this topc on msn [url:xfhf3qbh]http&#58;//msdn2&#46;microsoft&#46;com/en-us/library/ms676094&#46;aspx[/url:xfhf3qbh] However in most cases resync is working for me usually with some exceptions.
ADO update visability between workstations
I just checked on MSSQL server with a two column table. Resync of current row is working fine, after a different usr from a different workstation modifed the data through other frontend. No need to touch properties. ( do not modify the uniquely indexed column values). Please try again with some other simple table with atleast one unique index.
ADO update visability between workstations
Please try again with some other simple table with atleast one unique index Per your previous post .. as you suspected .. asigning the resync properties did not work .. Interesting .. I do not have any indexes .. none at all .. perhaps this is the reason it is failing. Rick Lipkin
ADO update visability between workstations
SUCCESS!!!!!!!!!!!!!! For the oRs:ReSync( 1,2 ) option to work .. you MUST have a PRIMARY KEY set and NOT NULL checked. No other changes to the syntax need to be made. ReSync() works perfectically and will update the visability of a changed record to a local cached recordset ! Thank you !! Rick Lipkin
ADO update visability between workstations
In future, if you get any ADO feature not working, put a standard routine to show the last ADO Error after CATCH. ADO Connection object contains an Errors collection. Last item of the Errors collection is the recent Error Object. Error object has these properties: Description, NativeError, Number, Source, SQL State, HelpContext, HelpFile. If we write a generic routine to show ADO last error and put it after each CATCH statement, we know what to do without losing much time.
ADO update() error
Hi All . I use use ADO to access MySql DB. I try modify a row using : [code=fw:18psgrge]<div class="fw" id="{CB}" style="font-family: monospace;"> </div>[/code:18psgrge] oRecordSet := TOleAuto():New( "ADODB.Recordset" ) oRecordSet:CursorType := adOpenDynamic oRecordSet:CursorLocation := adUseClient oRecordSet:LockType := adLockOptimistic TRY oRecordSet:Open( "SELECT filename FROM testi WHERE iddoc = 217 " , oConnection ) CATCH oErr MsgAlert( "Error to Open testi" ) END TRY oRecordset:Fields("filename" ):Value = "new value" oRecordset:update() [/code] but I get : [i:18psgrge]WINOLE/1007 Argument error: UPDATE[/i:18psgrge] any idea ? Best regards. Wzaf
ADO update() error
Perhaps in the select statement filename is a reserved word .. you might try : oRecordSet:Open( "SELECT [filename] FROM testi WHERE iddoc = 217 " , oConnection You can test the reserved by "select * from ......" then see if you update() fails .. if it does not fail ... filename may need to be in brackets .. Just a quick guess .. Rick Lipkin
ADO update() error
Tank you Rick , But I tried with different fields of the table, and I get always the same error: If I modify the field value, I get error in update method. In I modify nothing, the update() succeed !. Best regards Wzaf
ADO update() error
Maybe you don't have rights to write to the table?
ADO update() error
No, James, I have all rights for all DB . Tank you Wzaf
ADO update() error
Is the recordset empty? James
ADO update() error
No, it is filled with the result of Query: "SELECT filename FROM testi...." Wzaf