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, '"+@name.get_value+"', '"+@addl1.get_value+"', '"+@addl2.get_value+"', '"+@suburb.get_value+", '"+@pc.get_value+"', '"+@company.get_value+"', '"+@phone.get_value+"', '"+@fax.get_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.

Link to comment
Share on other sites

  • 2 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.