[Gambas-user] MySQL data access

Dag Jarle Johansen dag.jarle.johansen at ...2312...
Fri Feb 26 05:12:13 CET 2010


hi, seems like you have tendesial troubles ;)
in Gambas there are NO problems accessing a database.
I use it all the time, take a look at this;


'==================================================================================================
' CONNECT TO DATABASE
'==================================================================================================
Public Function Connect() As Boolean
    M.$Con.Close()                      ' Close the connection
    M.$Con.Type = "mysql"               ' Type of connection
    M.$Con.Host = "127.0.0.1"           ' Name of the server
    'M.$Con.Host = "192.168.1.101"      ' Name of the server
    M.$Con.Login = "developer"          ' User's name for the connection
    M.$Con.Port = "3306"                ' Port to use in the connection,
usually 3306
    M.$Con.Name = "generate"            ' Name of the data base we want
to use
    M.$Con.Password = "sunny2sys"       ' User's password
    Try M.$Con.Open()                       ' Open the connection
    If Error <> 0 Then
      Return False
    Else
      Return True
    Endif
End
works all the time

regards, Dag
'________________
Am Donnerstag, den 25.02.2010, 21:14 -0500 schrieb Keith Clark: 
> 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
> 
> 
> 
> ------------------------------------------------------------------------------
> Download Intel® Parallel Studio Eval
> Try the new software tools for yourself. Speed compiling, find bugs
> proactively, and fine-tune applications for parallel performance.
> See why Intel Parallel Studio got high marks during beta.
> http://p.sf.net/sfu/intel-sw-dev
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user







More information about the User mailing list