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.