Hola,
me están pidiendo una aplicación que se conecte a una base de datos en un servidor remoto.
¿como puedo conectar a esa base de datos? necesito abrir algún puerto para conectar?
Necesito un ejemplo que me pueda ayudar con la conexión.
Gracias anticipadas por su ayuda.
Saludos cordiales,
Luis Vasquez.
Hi
are calling me an application to connect to a database in a
remote server.
How I can connect to that database? need to open a port for
connect?
I need an example that can help me with the connection.
Thanks in advance for your help.
Best regards,
Luis Vasquez
Necesito su ayuda
Moderator: Rathinagiri
- luisvasquezcl
- Posts: 1259
- Joined: Thu Jul 31, 2008 3:23 am
- Location: Chile
- Contact:
- Rathinagiri
- Posts: 5480
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: Necesito su ayuda
Is it MySQL database?
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
- Roberto Lopez
- HMG Founder
- Posts: 4012
- Joined: Wed Jul 30, 2008 6:43 pm
Re: Necesito su ayuda
Si es una base de datos MySql, lo más fácil, es usar la la clases TMySql*.luisvasquezcl wrote:Hola,
me están pidiendo una aplicación que se conecte a una base de datos en un servidor remoto.
¿como puedo conectar a esa base de datos? necesito abrir algún puerto para conectar?
Necesito un ejemplo que me pueda ayudar con la conexión.
Gracias anticipadas por su ayuda.
Saludos cordiales,
Luis Vasquez.
Hi
are calling me an application to connect to a database in a
remote server.
How I can connect to that database? need to open a port for
connect?
I need an example that can help me with the connection.
Thanks in advance for your help.
Best regards,
Luis Vasquez
Los ejemplos están en \SAMPLES\MYSQL.*
Algunos servicios de hosting, por razones de seguridad, no permiten el acceso remoto a servidores MySql, en ese caso, debes crear algunos scripts en PHP para el servidor y accederlos via HBTIP. Hemos discutido la forma de hacerlo y se han posteado varios ejemplos aquí. Esta última, es la forma en la que yo trabajo, ya que permite acceso tanto con un cliente de escritorio escrito (por ejemplo en HMG) para Windows o con un cliente escrito en HTML+JavaScript para permitir el acceso en dispositivos móviles.
Google said:
If a MySql database, the easiest way is to use the TMySql classes *.
The examples are in \ SAMPLES \ MYSQL .*
Some hosting services, for security reasons, do not allow remote access to MySQL servers, in this case, you create some PHP scripts for the server and access them via HBTIP. We discussed how to do it and have posted several examples here. This last is the way I work, since it allows access to both a desktop client in writing (eg HMG) for Windows or a client written in HTML + JavaScript to allow access on mobile devices.
Esta es la referencia / This is the reference:
*******************************************************************************
* MySql Harbour Contribution Library
*******************************************************************************
-------------------------------------------------------------------------------
CLASS TMySQLRow: Every single row of an answer
-------------------------------------------------------------------------------
DATA aRow
A single row of answer
DATA aDirty
Array of booleans set to .T. if corresponding field of aRow has
been changed
DATA aOldValue
If aDirty[n] is .T. aOldValue[n] keeps a copy of changed value
if aRow[n] is part of a primary key
DATA aOriValue
Original values ( same as TMySQLtable:aOldValue )
DATA aFieldStruct
Type of each field
DATA cTable
Name of table containing this row, empty if TMySQLQuery returned
this row
METHOD New(aRow, aFStruct, cTableName)
Create a new Row object
METHOD FieldGet(cnField)
Same as clipper ones, but FieldGet() and FieldPut() accept a
string as
METHOD FieldPut(cnField, Value)
Field identifier, not only a number
METHOD FieldName(nNum)
METHOD FieldPos(cFieldName)
METHOD FieldLen(nNum)
Length of field N
METHOD FieldDec(nNum)
How many decimals in field N
METHOD FieldType(nNum)
Clipper type of field N
METHOD MakePrimaryKeyWhere()
Returns a WHERE x=y statement which uses primary key (if
available)
-------------------------------------------------------------------------------
CLASS TMySQLQuery: Every single query submitted to MySQL server
-------------------------------------------------------------------------------
DATA nSocket
Connection handle to MySQL server
DATA nResultHandle
Result handle received from MySQL
DATA cQuery
Copy of query that generated this object
DATA nNumRows
Number of rows available on answer NOTE MySQL is 0 based
DATA nCurRow
I'm currently over row number
DATA lBof
DATA lEof
DATA lFieldAsData
Use fields as object DATA. For compatibility
Names of fields can match name of TMySQLQuery/Table DATAs,
and it is dangerous. ::lFieldAsData:=.F. can fix it
DATA aRow
Values of fields of current row
DATA nNumFields
How many fields per row
DATA aFieldStruct
Type of each field, a copy is here a copy inside each row
DATA lError
.T. if last operation failed
METHOD New(nSocket, cQuery)
New query object
METHOD Destroy()
METHOD End()
METHOD Refresh()
ReExecutes the query (cQuery) so that changes to table are
visible
METHOD GetRow(nRow)
Return Row n of answer
METHOD Skip(nRows)
Same as clipper ones
METHOD Bof()
METHOD Eof()
METHOD RecNo()
METHOD LastRec()
METHOD GoTop()
METHOD GoBottom()
METHOD GoTO(nRow)
METHOD FCount()
METHOD NetErr()
Returns .T. if something went wrong
METHOD Error()
Returns textual description of last error and clears ::lError
METHOD FieldName(nNum)
METHOD FieldPos(cFieldName)
METHOD FieldGet(cnField)
METHOD FieldLen(nNum)
Length of field N
METHOD FieldDec(nNum)
How many decimals in field N
METHOD FieldType(nNum)
Clipper type of field N
-------------------------------------------------------------------------------
CLASS TMySQLTable: A query without joins; Insert() e Delete() rows are allowed.
-------------------------------------------------------------------------------
NOTE: it's always a SELECT result, so it will contain a full table only if
SELECT * FROM ... was issued
DATA cTable
Name of table
DATA aOldValue
Keeps a copy of old value
METHOD New(nSocket, cQuery, cTableName)
METHOD GetRow(nRow)
METHOD Skip(nRow)
METHOD GoTop()
METHOD GoBottom()
METHOD GoTo(nRow)
METHOD Update(oRow, lOldRecord, lRefresh)
Gets an oRow and updates changed fields
METHOD Save()
METHOD Delete(oRow, lOldRecord, lRefresh)
Deletes passed row from table
METHOD Append(oRow, lRefresh)
Inserts passed row into table
METHOD GetBlankRow( lSetValues )
Returns an empty row with all available fields empty
METHOD SetBlankRow()
Compatibility
METHOD Blank()
METHOD FieldPut(cnField, Value)
Field identifier, not only a number
METHOD Refresh()
METHOD MakePrimaryKeyWhere()
Returns a WHERE x=y statement which uses primary key (if
available)
-------------------------------------------------------------------------------
CLASS TMySQLServer: Every available MySQL server
-------------------------------------------------------------------------------
DATA nSocket
Connection handle to server (currently pointer to a MYSQL structure)
DATA cServer
Server name
DATA cDBName
Selected DB
DATA cUser
User accessing db
DATA cPassword
His/her password
DATA lError
.T. if occurred an error
DATA cCreateQuery
METHOD New(cServer, cUser, cPassword)
Opens connection to a server, returns a server object
METHOD Destroy()
Closes connection to server
METHOD SelectDB(cDBName)
Which data base I will use for subsequent queries
METHOD CreateTable(cTable, aStruct,cPrimaryKey,cUniqueKey,cAuto)
Create new table using the same syntax of dbCreate()
METHOD DeleteTable(cTable)
Delete table
METHOD TableStruct(cTable)
Returns a structure array compatible with clipper's dbStruct()
ones
METHOD CreateIndex(cName, cTable, aFNames, lUnique)
Create an index (unique) on field name(s) passed as an array of
strings aFNames
METHOD DeleteIndex(cName, cTable)
Delete index cName from cTable
METHOD ListDBs()
Returns an array with list of data bases available
METHOD ListTables()
Returns an array with list of available tables in current
database
METHOD Query(cQuery)
Gets a textual query and returns a TMySQLQuery or TMySQLTable
object
METHOD NetErr() INLINE ::lError
Returns .T. if something went wrong
METHOD Error()
Returns textual description of last error
METHOD CreateDatabase( cDataBase )
Create an New Mysql Database
METHOD sql_Commit()
Commits transaction
METHOD sql_Rollback()
Rollbacks transaction
METHOD sql_Version()
Server version as numeric
Regards/Saludos,
Roberto
(Veritas Filia Temporis)
Roberto
(Veritas Filia Temporis)
- luisvasquezcl
- Posts: 1259
- Joined: Thu Jul 31, 2008 3:23 am
- Location: Chile
- Contact:
Re: Necesito su ayuda
Rathi,
Voy a usar una base de datos mysql ya que está probado que es la mejor para este tipo de aplicaciones.
Roberto,
gracias por la explicación; voy a revisar los ejemplos y probablemente haga algunas consultas más.
Gracias por su tiempo.
saludos cordiales,
luis vasquez.
Voy a usar una base de datos mysql ya que está probado que es la mejor para este tipo de aplicaciones.
Roberto,
gracias por la explicación; voy a revisar los ejemplos y probablemente haga algunas consultas más.
Gracias por su tiempo.
saludos cordiales,
luis vasquez.
- Ismach
- Posts: 164
- Joined: Wed Nov 28, 2012 5:55 pm
- DBs Used: DBF, mySQL, Mariadb, postgreSQL, Oracle, Db2, Interbase, Firebird, and SQLite
- Location: Buenos Aires - Argentina
Re: Necesito su ayuda
Recomiendo Mariadb, Hijo menor de MySQL pero mejor que Mysql y totalmente compatible, desarrollada y mandenida por el Creador de Mysql (Mr Monty ).