[Gambas-user] Connecting to Postgres (was Q in an event keypress header)

Arief Bayu Purwanto ariefbayu at ...626...
Fri Jan 11 05:15:57 CET 2008


add a gridview and paste this code:

' Gambas class file

PRIVATE conn AS Connection

PUBLIC SUB Form_Open()

  initGrid()
  make_connection()
  populateGrid()

END

PRIVATE SUB populateGrid()
  DIM res AS Result
  res = conn.EXEC("SELECT * FROM wpexport_domains")
  FOR EACH res
    GridView1.Rows.count = GridView1.Rows.count + 1
    GridView1[GridView1.Rows.Count - 1, 0].Text = res!dom_id
    GridView1[GridView1.Rows.Count - 1, 1].Text = res!dom_name
    GridView1[GridView1.Rows.Count - 1, 2].Text = res!dom_target
    GridView1[GridView1.Rows.Count - 1, 3].Text = res!username
    GridView1[GridView1.Rows.Count - 1, 4].Text = res!password
  NEXT

END

PRIVATE SUB initGrid()

  GridView1.Columns.Count = 5
  GridView1.Columns[0].Width = 88
  GridView1.Columns[1].Width = 168
  GridView1.Columns[2].Width = 80
  GridView1.Columns[3].Width = 112
  GridView1.Columns[4].Width = 120

END


PRIVATE FUNCTION make_connection() AS Boolean

  conn = NEW Connection
  WITH conn
  .Type = "mysql"
  .Host = "localhost"
  .Login = "xxxxxxxxxx"
  .Password = "xxxxxxxxxx"
  .Name = "wp_export"
  END WITH

  TRY conn.OPEN
  IF ERROR THEN
  Message("Cannot open database. Error = " & Error.Text)
  RETURN FALSE
  END IF
  RETURN TRUE


On 1/11/08, gunartha.nyoman <gunartha.nyoman at ...1817...> wrote:
>
> ok, thank for your reply
> the connection is ok, and then i want to see or fill data from a table
> (for
> example: tbldata)  from server to screen/monitor. I use version gambas2
> 1.1.91and in toolbox I  see gridview or tableview. my problem is how to
> use
> that control to see/fill data.
>
> Many thank for your help.
>
> Regards
> Gunartha
>
>
> On Friday 11 January 2008 09:27:28 am richard terry wrote:
> > Firstly I'd subclass your requests in different emails so as to not mix
> up
> > topics as above otherwise in the long run no-one will know about the
> > content - ie the header won't reflect the content.
> >
> > I'm assuming you want something basic, so with reference to your
> database
> > thingy, here's a few lines of code to connect to an existing progress
> > database with obviously postmaster running.
> >
> > It is essentially the same as the code in the database example except
> that
> > the parameters are for postgres. You can get the rest of the code from
> the
> > example. If you are already past that stage then I'll pass you on to
> more
> > knowledgeable others.
> >
> >
> >
> > PRIVATE FUNCTION make_connection() AS Boolean
> >
> >
> > WITH conn
> > .Type = "postgresql"
> > .Host = "localhost"
> > .Login = "yourlogon"
> > .Password = "your password"
> > .Name = "yourdatabasename"
> > END WITH
> >
> > TRY conn.OPEN
> > IF ERROR THEN
> > Message("Cannot open database. Error = " & Error.Text)
> > RETURN FALSE
> > END IF
> > RETURN TRUE
> > END
> >
> > > hi all,
> > >
> > > I am trying to use gambas. Please help me about code to resolve my
> > > problem 1. How to move cursor when I press key enter on keyboard ?
> > > 2. How to fill data from database (as a postgres database server) to
> > > gridview or table view. ?
> > >
> > > Regards
> > > Gunartha
> > >
> > >
> -------------------------------------------------------------------------
> > > Check out the new SourceForge.net Marketplace.
> > > It's the best place to buy or sell services for
> > > just about anything Open Source.
> > >
> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketpl
> > >ac e _______________________________________________
> > > Gambas-user mailing list
> > > Gambas-user at lists.sourceforge.net
> > > https://lists.sourceforge.net/lists/listinfo/gambas-user
> >
> >
> -------------------------------------------------------------------------
> > Check out the new SourceForge.net Marketplace.
> > It's the best place to buy or sell services for
> > just about anything Open Source.
> >
> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplac
> >e _______________________________________________
> > Gambas-user mailing list
> > Gambas-user at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gambas-user
>
>
>
> -------------------------------------------------------------------------
> Check out the new SourceForge.net Marketplace.
> It's the best place to buy or sell services for
> just about anything Open Source.
>
> http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>



-- 
Daiguren Hyōrinmaru<http://en.wikipedia.org/wiki/Toshiro_Hitsugaya#Hy.C5.8Drinmaru>


More information about the User mailing list