Empezando con ADO

Empezando con ADO

Postby cnavarro » Thu Sep 19, 2013 8:06 pm

Buenas
Quisiera dar el salto en el uso de motores de bases de datos, y despues de leer y mirar, creo que ADO es una buena opción, sin dejar de lado otras alternativas.
Mis conocimientos en este tema son minimos, por lo que solicito inicialmente ayuda.
He estado leyendo los post de este foro para ir entendiendo el tema, aunque soy bastante torpe.
Mi idea es empezar a usar ADO con las propias bases de datos DBF (NTX) que estoy usando, para entender su funcionamiento en comparación con la sintaxis actual.
Pero no encuentro Drivers DBase con NTX, cómo he de usarlas?
¿Es posible?, y sobre todo, entiendo que, para qué usar ADO si ya las puedo usar nativamente, pero como he dicho, no me gustaria cambiar a la vez el motor de base de datos y la sintaxis de utilización. Ese es mi planteamiento (quizás incorrecto) y el concepto sea erróneo, disculpen.
Agradezco cualquier ayuda, guia o comentario.

good
I would like to jump in the use of database engines, and after reading and looking, I think ADO is a good choice, without neglecting other alternatives.
My knowledge in this area are minimal, so initially request help.
I've been reading posts on this forum to begin to understand the subject, but I'm pretty clumsy.
My idea is to start using ADO with DBF databases themselves (NTX) I'm using, to understand its performance compared with the current syntax.
But I find DBase Drivers NTX, how do I use them?
Is it possible?, And above all, understand that, why use ADO if I can use and natively, but like I said, I would like to change both the database engine and syntax to use. That's my approach (perhaps wrongly) and the concept is wrong, sorry.
I appreciate any help, guidance or comments.
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6498
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Empezando con ADO

Postby Rick Lipkin » Fri Sep 20, 2013 12:59 pm

Cristobal

Microsoft ActiveX Data Objects (ADO)

ActiveX Data Objects (ADO) consists of the following components:
ADO

Microsoft ActiveX Data Objects (ADO) enable your client applications to access and manipulate data from a variety of sources through an OLE DB provider. Its primary benefits are ease of use, high speed, low memory overhead, and a small disk footprint. ADO supports key features for building client/server and Web-based applications.


The above definition came from Microsoft's website
http://msdn.microsoft.com/en-us/library ... 85%29.aspx

.Dbf,.ntx\.cdx grew out of the dBase\Foxpro platforms that started the xBase language and therefore those platforms became native to the compilers we have today... ( no sense re-inventing the wheel ). Ado is more designed to share data between cross platforms that are designed to do so with an OLE DB provider. For example, you can use Ado to open an Excel spreadsheet and extract and share data between ( lets say ) Ms Access, or MsSql Server or for that matter any ADO compliant RDMS... or even opening an Ado Sql table and sharing the data with .dbf using the correct xBase RDD.

.Dbf\.ntx\.cdx does not ( really ) lend itself to Ado with the only exception being Visual Foxpro which does manipulate .dbf\cdx through the FoxPro Ole Provider .. which is mostly proprietary.

http://www.microsoft.com/en-us/download ... x?id=14839

There are .dbf Classes that use object oriented code to encapsulate the traditional xBase commands tData I believe is one of them. Please do not confuse object oriented xBase data management code with ADO, though similar in their methods, ADO targets the Microsoft Office products and data management between those applications as well as ( most any ) Sql RDMS's through their respective OLE Db providers.

One nice thing Microsoft has traditionally done is include their MS Jet and SQLOLE db providers in every Windows operating system from XP up to and including Windows 8, meaning that the developer does not need to copy\install or setup any separate or 3rd party 'run-time' or Ole providers with the distribution of their application. The Ms ADO class provides a consistent set of methods for data manipulation.. basically code the database and table calls once and you can with little or no code changes, change your back-end to Ms Access, Ms Sql Server, Oracle, dB2, My Sql, Sql Lite ( etc ) with only a change of the OleDb Provider.

Again .. the choice of your database depends on how you wish to distribute your application .. Only Ms Access (.mdb ) and Ms Sql Server have built in Windows support, if you chose any of the other RDMS you will need a 3rd party OleDb provider to accompany your application.

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2606
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Empezando con ADO

Postby cnavarro » Fri Sep 20, 2013 4:38 pm

Mr. Rick
Muy, muy agradecido, y muchas gracias por su explicacion
Efectivamente, tenia un problema de conceptos
Hace unos años hice algunas pruebas con Eagle y Mysql, pero he estado retirado de la programacion durante algun tiempo. Tambien queria probar Dolphin.
Pero, he oido tanto hablar de ADO en el foro que he querido introducirme en este tema y ver su alcance. Sí habia entendido que con ADO se podia usar cualquier base de datos soportada y el codigo era practicamente el mismo y lo hacia muy bueno para ser probado.
Intentaré ir probando poco a poco y preguntando mis posibles dudas que no encuentre en este foro y google.
Que bases de datos usa usted?

Mr. Rick
Very, very grateful, and thank you very much for your explanation
Indeed, I had a problem of concepts
A few years ago I did some tests with Eagle and Mysql, but I've been retired for some time programming. I also wanted to try Dolphin.
But, I've heard talk of ADO in the forum that I wanted to introduce myself on this subject and see its scope. Yes ADO had understood that it could use any supported database and the code was almost the same and made it too good to be tested.
Try keep trying little by little and asking my possible questions you can not find in this forum and google.
What database do you use?
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6498
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Empezando con ADO

Postby Rick Lipkin » Fri Sep 20, 2013 5:06 pm

Cristobal

I like to use Ms Access for desktop and small networked applications and Sql Server for larger Corporate Enterprise programs. Since Ms Access and Sql Server have native Windows support .. all I have to do is distribute my executable .. no client, no run-time, no dot net.

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2606
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Empezando con ADO

Postby cnavarro » Fri Sep 20, 2013 5:26 pm

Rick Lipkin wrote:Cristobal

I like to use Ms Access for desktop and small networked applications and Sql Server for larger Corporate Enterprise programs. Since Ms Access and Sql Server have native Windows support .. all I have to do is distribute my executable .. no client, no run-time, no dot net.

Rick Lipkin


Su planteamiento es sencillo y muy practico, me parece muy bien.
Pocas personas he visto que con Fivewin usen esas bases de datos.

His approach is simple and very practical, it seems very good.
Few people have seen that Fivewin use those databases.

(no need to reinvent the wheel)


Por cierto, es muy buena cita

Certainly, is very good quote
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6498
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Empezando con ADO

Postby Antonio Linares » Fri Sep 20, 2013 5:34 pm

Cristobal,

Desde FiveDBU permitimos abrir bases de datos con ADO, en donde puedes navegar, añadir, editar y borrar registros, hacer búsquedas y consultas, e impresión.

FiveDBU se proporciona con todo su código fuente, por lo que ya es un gran avance si vas a construir una aplicación usando ADO, solo copiar y adaptar a tus necesidades ó al menos te puede ayudar en entender como usar ADO :-)

https://code.google.com/p/fivewin-contributions/downloads/detail?name=fivedbu_20130909.zip
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41206
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Empezando con ADO

Postby Antonio Linares » Fri Sep 20, 2013 5:36 pm

Rick,

I like to use Ms Access for desktop and small networked applications and Sql Server for larger Corporate Enterprise programs. Since Ms Access and Sql Server have native Windows support .. all I have to do is distribute my executable .. no client, no run-time, no dot net.


I am also using ms Access for desktop on some developments, and it is working fine on all PCs without the need to install anything :-)

Except on a laptop where there are several Access ODBC drivers installed but seem to fail when the app tries to execute. Do you know how to remove those different Access drivers and leave just the right one ? thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41206
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Empezando con ADO

Postby Rick Lipkin » Fri Sep 20, 2013 6:04 pm

Antonio

I am not a fan of Odbc and prefer to use the Jet Ole provider... Check your \windows\system32\MsJet40.dll .. that is the Ole Provider for Jet. If MsJet40.dll ( 32 bit ) is not there you can re-install from Microsoft ..

http://support.microsoft.com/kb/239114

What does your connection string look like ?.. are you using ODBC or Ole ?

Thanks
Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2606
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Empezando con ADO

Postby cnavarro » Fri Sep 20, 2013 6:39 pm

Antonio Linares wrote:Cristobal,

Desde FiveDBU permitimos abrir bases de datos con ADO, en donde puedes navegar, añadir, editar y borrar registros, hacer búsquedas y consultas, e impresión.

FiveDBU se proporciona con todo su código fuente, por lo que ya es un gran avance si vas a construir una aplicación usando ADO, solo copiar y adaptar a tus necesidades ó al menos te puede ayudar en entender como usar ADO :-)

https://code.google.com/p/fivewin-contributions/downloads/detail?name=fivedbu_20130909.zip


Antonio
Precisamente, el ver el funcionamiento de Fivedbu y empezar a mirar su codigo es lo que me ha animado a empezar con el tema.
Pero tengo muchas dudas, son los lógicos comienzos.
Seguire por aqui solicitando ayuda

Antonio
Indeed, seeing Fivedbu operation and start looking at your code is what has encouraged me to start with the topic.
But I have many doubts, are the logical beginning.
Here Seguire for help
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6498
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Empezando con ADO

Postby cnavarro » Fri Sep 20, 2013 6:44 pm

Rick Lipkin wrote:Antonio

I am not a fan of Odbc and prefer to use the Jet Ole provider...


Mr. Rick

Que motivo especial tiene?
Este tema es muy importante para mi

It has special reason?
This issue is very important to me
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6498
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Empezando con ADO

Postby Rick Lipkin » Fri Sep 20, 2013 6:54 pm

Cristobal

You have to configure ODBC on every computer .. not my idea of a 'good' time .. when I worked in State government I had 3k desktops I had to run on. The OleDb providers MsJet and SqlOleDb are already installed in Windows for you with no configuration needed.. :shock:

Rick Lipkin

Image
User avatar
Rick Lipkin
 
Posts: 2606
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Empezando con ADO

Postby cnavarro » Fri Sep 20, 2013 7:12 pm

Mr. Rick
Cada mensaje me ayudas mas a tener el tema mas claro
Sin tener que instalar nada, ni soporte especial en cada ordenador
Era un tema que tambien me preocupaba bastante.
Gracias de nuevo

Each message helps me to have the issue more clearer
Without having to install any special support on each computer
It was an issue that concerned me quite well.
Thanks again
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6498
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Empezando con ADO

Postby cnavarro » Fri Sep 20, 2013 7:26 pm

Una pregunta
Un consejo para convertir DBF a MDB sin tener instalado Access?
He pensado en usar MicrosoftJet para hacer una rutina que lea los DBF y que los pase a MDB, es posible?

a question
A tip to convert DBF to MDB without Access installed?
I thought about using MicrosoftJet to make a routine to read the DBF and MDB pass that is possible?
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6498
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: Empezando con ADO

Postby Antonio Linares » Fri Sep 20, 2013 7:39 pm

Cristobal,

Puedes usar la misma estructura de tus DBFs y usar las funciones de FWH para crear la base de datos y las tablas en Access:

1. Crear la base de datos si no existe:
Code: Select all  Expand view
  if ! File( "database.mdb" )
      if MsgYesNo( "database.mdb not found" + CRLF + "Do you want to create it ?" )
         if ! FW_CreateMdb( "database.mdb" )
            MsgAlert( "can't create database.mdb. App will finish" )
            return .F.
         endif
      else
         return .F.  
      endif
   endif


2. A continuación crear las tablas usando la estructura de tus DBFs:
oCon = TOleAuto():New( "ADODB.Connection" )

oCon:Open( "Provider='Microsoft.Jet.OLEDB.4.0'; Data Source='database.mdb';" )

Code: Select all  Expand view
  if ! FW_AdoTableExists( "usuarios", oCon )
      FWAdoCreateTable( "usuarios", DbStruct(), oCon, .T. )  // DbStruct() devuelve la estructura de tu DBF usuarios.dbf  
  endif
 


3. Para trabajar con una tabla:

oRsUsuarios = AdoOpenTable( oCon, "usuarios" )

Code: Select all  Expand view
function AdoOpenTable( oCon, cTableName, cExtra )

   local oRs := TOleAuto():New( "ADODB.Recordset" )
   
   oRs:CursorType     = 1        // opendkeyset
   oRs:CursorLocation = 3        // local cache
   oRs:LockType       = 3        // lockoptimistic
   
   if Empty( cExtra )
      oRs:Open( "SELECT * FROM " + cTableName, oCon )
   else  
      oRs:Open( "SELECT * FROM " + cTableName + " " + cExtra, oCon )
   endif

return oRs


Rao me ha indicado que para una apertura normal de la tabla, se puede abrir por su nombre sin tener que usar "SELECT * FROM".
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41206
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Empezando con ADO

Postby cnavarro » Fri Sep 20, 2013 7:44 pm

Genial Antonio
Esto es un paso de gigante para empezar
Ya se empieza a ver la luz

great Antonio
This is a giant step to begin
Now you begin to see the light
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6498
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Next

Return to Off Topic / Otros temas

Who is online

Users browsing this forum: No registered users and 6 guests