FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index Off Topic / Otros temas Empezando con ADO
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Empezando con ADO
Posted: Thu Sep 19, 2013 08: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
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Empezando con ADO
Posted: 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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Empezando con ADO
Posted: Fri Sep 20, 2013 04: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
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Empezando con ADO
Posted: Fri Sep 20, 2013 05: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

Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Empezando con ADO
Posted: Fri Sep 20, 2013 05: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Empezando con ADO
Posted: Fri Sep 20, 2013 05: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Empezando con ADO
Posted: Fri Sep 20, 2013 05: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
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Empezando con ADO
Posted: Fri Sep 20, 2013 06: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

Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Empezando con ADO
Posted: Fri Sep 20, 2013 06: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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Empezando con ADO
Posted: Fri Sep 20, 2013 06: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
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Empezando con ADO
Posted: Fri Sep 20, 2013 06: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.. :-)

Rick Lipkin

Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Empezando con ADO
Posted: Fri Sep 20, 2013 07: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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Empezando con ADO
Posted: Fri Sep 20, 2013 07: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Empezando con ADO
Posted: Fri Sep 20, 2013 07: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 (fw): Select all Collapse
 聽 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 (fw): Select all Collapse
 聽 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 (fw): Select all Collapse
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
Posts: 6755
Joined: Wed Feb 15, 2012 08:25 PM
Re: Empezando con ADO
Posted: Fri Sep 20, 2013 07: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