11-23-2009 12:30 PM
11-24-2009 02:14 PM
Hi dsalcido,
You can use the following example:
/* This sample program simply connects to a database and then */
/* disconnects from the database. */
#include "cvi_db.h"
#include <ansi_c.h>
#include <userint.h>
void ShowError()
{
MessagePopup("Database Error",DBErrorMessage());
}
void main()
{
int hdbc = 0; /* Handle to database connection */
int resCode; /* Result code */
/* Connect to database (in this case dBase files) */
hdbc = DBConnect ("DSN=CVI SQL Samples");
if (hdbc <= 0) {ShowError(); goto Error;}
/* Disconnect from database */
resCode = DBDisconnect (hdbc);
if (resCode != DB_SUCCESS) {ShowError(); goto Error;}
MessagePopup ("Connect Sample",
"Successfully connected to and disconnected from CVI_Samples data source");
return;
Error:
return;
}
If you prefer you can browse in Help>Find Examples... clic on the Search tab and write database, there are some hepful examples.
Best Regards.
11-24-2009 02:19 PM
Hi dsalcido!
The best way to start is by checking out the examples installed with your toolkit. There is also an example on the web that is related to this action. The online example is:
http://zone.ni.com/devzone/cda/epd/p/id/3627
To access the examples installed with the Toolkit go to the find examples and select the Toolkits Category.
Hope this helps.
Have a great day!!
11-25-2009 03:06 PM
thank you, i saw this examples and loos interesting.. but i have a problem with the OBDC driver, maybe i did a bad configuration.
11-25-2009 03:32 PM
hola arturo, tengo una duda en esta parte del codigo
hdbc = DBConnect ("DSN=CVI SQL Samples");
para hacer la conexion con el mdb, se utiliza DBCONNECT , necesito realizar la configuracion dns en el obdc antes para indicar el path de la mdb?
donde peudo ver el DSN que se utilizan en los ejemplos para basarme en el? para crear el mio.
11-25-2009 04:19 PM
hola dsalcido,
Si, antes de utilizar las herramientas de CVI, debes registrar tu base de datos ya sea como System DSN o como File DSN en Windows (Control Panel>Administrative Tools>Data Sources (ODBC)). Una vez que registres tu base de datos ya solo es cuestión de sustituir CVI SQL Samples por el nombre con el que registraste la tuya.
Saludos.