[Gambas-user] MySQL data access

Keith Clark keithclark at ...2185...
Fri Feb 26 03:14:37 CET 2010


On Thu, 2010-02-25 at 20:10 -0500, Keith Clark wrote:
> I am having some trouble understanding MySQL access.  I am new to Gambas
> so you may have to take it easy on me!
> 
> Ok, I followed the instructions as per:
> 
> http://gambasdoc.org/help/howto/database
> 
> And I'm now trying to insert my first record into a populated database.
> Here is my code to do so:
> 
> PUBLIC SUB ISBN_Enter()
> 
>   DIM $Result AS Result
>   
>   ' DatabaseConnection.Connect()
>   
>   DatabaseConnection.$Con.Begin
>     $Result = DatabaseConnection.$Con.Create("tblStoreSales")
>     ' $Result!salesID = "NULL"
>     ' $Result!Date = Now
>     $Result!ISBN = ISBN.Text
>     $Result!Quantity = 1
>     $Result!customerID = 0
>     $Result!merged = 0
>     $Result!salespersonID = 0
>   DatabaseConnection.$Con.Commit()
>   
>   ISBN.text = ""
> 
> END
> 
> No, when the form opens I call the Connect() instead of every time the
> text box has changed.
> 
> Now, when I enter a value into the text box nothing seems to happen for
> a few moments, then it clears as it is supposed to, but no data is in
> the table in the database.
> 
> I'm pretty sure it is connected, as if I put a sting in for a number, it
> gives me an error.
> 
> Not sure how to troubleshoot this or even where good documentation is
> for this type of operation other that what I have shown above.
> 
> Keith
> 
> 

Ok, I see what I did wrong!  I forgot the Update.  Sorry about that, I'm
still learning.

Keith






More information about the User mailing list