Jump to content

[RUBY] Ruby, wxRuby and MySQL. One not working correctly?


Recommended Posts

I've been trying to write an application that can connect to a database using Ruby and wxRuby.

When I click a button I want the program to connect to a MySQL database (I'm using DBI), insert some data and then disconnect but so far I am not having any luck. Also, I'm on Windows.

 

Here's the code that handles the connection:

evt_button(22) { |event| button_save_clicked(event) } // This code is for the form with the button.

  def button_save_clicked(event)
    @sql = DBI.connect("DBI:Mysql:invoicer:localhost", "root", nil)
    @query = "insert into `customers` VALUES (null, '"[email protected]_value+"', '"[email protected]_value+"', '"[email protected]_value+"', '"[email protected]_value+", '"[email protected]_value+"', '"[email protected]_value+"', '"[email protected]_value+"', '"[email protected]_value+"')"
    @sql.do(@query)
    self.destroy
  end

 

Anyone have any ideas? Also I'm kind of new to Ruby so if I'm doing anything silly then please also tell me so I don't keep making the same mistakes.

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.