Hi:
I am makeing a basic program with wxruby.
Is a frame with a Wx::Notebook inside.
The notebook has two tabs.
The first tab has a grid with 3 columns.
I am using dbi to load data from database, to fill the rows.
But the column 3 that is a description, is not fill when the
description
has special characters like ‘ç, é, ñ’;
But dbi returns the special characters, i create a file to write the
returned data for test.
And when i edit the file the text are ok.
My program is :
require ‘wx’;
require “dbi”;
class BasicGridApp < Wx::App
def on_init
begin
@frame = Wx::Frame.new( nil , -1 , "Basic Grid Application",
Wx::Point.new(10,10),
Wx::Size.new(760,550) );
@note = Wx::Notebook.new( @frame, -1, Wx::Point.new(0,0),
Wx::Size.new(400,400), 0,
"NoteBook" );
@TabWindow = Wx::Window.new( @note, -1, Wx::Point.new(0,0),
Wx::Size.new(100,100), 0, “Tab1”);
@TabWindow1 = Wx::Window.new( @note, -1, Wx::Point.new(0,0),
Wx::Size.new(100,100), 0, “Tab2”);
@grid = Wx::Grid.new( @TabWindow , -1, Wx::Point.new(0,0),
Wx::Size.new(400,400), 0, “Grid”);
@grid.create_grid( 40 , 4 );
@grid.set_col_label_value( 0, "ID" );
@grid.set_col_label_value( 1, "Avreviação" );
@grid.set_col_label_value( 2, "Descrição" );
@grid.set_col_label_size( 24 );
@grid.set_row_label_size( 24 );
# connect to the MySQL server
dbh = DBI.connect("DBI:Mysql:test:localhost", "test",
“er5aa5h”);
sth = dbh.execute("SELECT iduf, ufdesc, descricao COLLATE
latin1_bin AS descricao FROM uf ");
contador = 0;
sth.each do |row|
@grid.set_col_format_number( 0 );
@grid.set_cell_value( contador, 0, row[0].to_s ); # ID
@grid.set_cell_value( contador, 1, row[1] ); #
short
description
@grid.set_cell_value( contador, 2, row[2] ); #
description
contador += 1;
end
sth.finish;
rescue DBI::DatabaseError => e
puts "An error occurred";
puts "Error code: #{e.err}";
puts "Error message: #{e.errstr}";
ensure
# disconnect from server
dbh.disconnect if dbh;
end
@note.add_page( @TabWindow, "Titulo1", true, -1);
@note.add_page( @TabWindow1, "Titulo2", false, -1);
@frame.show();
end
end
b = BasicGridApp.new();
b.main_loop();
Can you give my some ligth?
Thanks in advance
avast! Antivirus http://www.avast.com : Outbound message clean.
Virus Database (VPS): 090219-0, 19/02/2009
Tested on: 20/02/2009 11:14:33
avast! - copyright (c) 1988-2009 ALWIL Software.