Re: [gnome-db]Hi...



On Tue, Jul 03, 2001 at 12:05:50PM +0200, Rodrigo Moya wrote:
> hmm, strange. Is the MySQL server correctly set up to accept connections
> for the user/host you're using to connect?
	Yes, I execute mysql -u root here and I connect without problems.
	
> GdaDsn *dsn;
> GdaConnection *cnc;
> 
> dsn = gda_dsn_find_by_name ("dsn_name");
> if (dsn) {
> 	cnc = gda_connection_new (gda_corba_get_orb ());
> 	gda_connection_set_provider (cnc, GDA_DSN_PROVIDER (dsn));
> 	gda_connection_open (cnc, GDA_DSN_DSN (dsn), username, password);
> }
> 
> Anyway, I'm going to add right now a new function so that you'll be able
> to do the same as before with just doing:
> 
> cnc = gda_connection_new_from_dsn ("dsn_name");
Ok.
I created a dsn and didi it, but it doesn't work.
The code I have used is the following:


/*************************************/

#ifdef HAVE_CONFIG_H
#  include <config.h>
#endif

#include <gnome.h>
#include <gnome-db.h>

#include "interface.h"
#include "support.h"
#include "main.h"

int
main (int argc, char *argv[])
{

#ifdef ENABLE_NLS
  bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
  textdomain (PACKAGE);
#endif

  gnome_db_init ("prj1", VERSION, argc, argv);

  /*
   * The following code was added by Glade to create one of each component
   * (except popup menus), just so that you see something after building
   * the project. Delete any components that you don't want shown initially.
   */
  window1 = create_window1 ();
  //Create the connection
  cnc =  gda_connection_new (gda_corba_get_orb ());
  //Create the data source
  dsn = gda_dsn_new();
  gda_dsn_set_name(dsn, "nome");
  gda_dsn_set_description(dsn, "desc");
  gda_dsn_set_passwd(dsn, "");
  gda_dsn_set_username(dsn, "usname");
  gda_dsn_set_provider(dsn, "OAFIID:GNOME_GDA_Provider_MySQL_ConnectionFactory");
  gda_dsn_set_dsn(dsn, "HOST=localhost;DATABASE=electricengclub;USERNAME=root;PASSWORD=;PORT=3306;UNIX_SOCKET=;FLAGS=;");

  //Open the connection
  gda_connection_set_provider (cnc, GDA_DSN_PROVIDER (dsn));
  g_print("Open status: %d\n",
    gda_connection_open (cnc, GDA_DSN_DSN (dsn), "usname", "")
	 );
  //Executes the query
  {
    gulong reccount;
    GtkWidget *grid;
    GdaRecordset *recset;
    grid = lookup_widget(window1, "dbgrid1");
    recset = gda_connection_execute (cnc, "select * from members", &reccount, 0);
    gnome_db_grid_set_recordset ((GnomeDbGrid *)grid, recset);
    
    
  }
  gtk_widget_show (window1);

  gtk_main (gtk_main);
  return 0;
}
/*************************************/


And I got the following errors:


GDA_Connection_open returns -1
Open status: -1

** CRITICAL **: file gda-connection.c: line 901 (gda_connection_execute):
assertion `gda_connection_is_open(cnc)' failed.





-- 
Marcelo Elias Del Valle    UIN: 30595143
marceloelias iname com http://mlinuxer.cjb.net MLinuxer
The game of Evolution http://Evolution.sourceforge.net
Clube da Engenharia Elétrica http://electricengclub.sourceforge.net





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]