New topic: RB 2009 v5 + mySQL + Newbie
<http://forums.realsoftware.com/viewtopic.php?t=31365> Page 1 of 1 [ 2 posts ] Previous topic | Next topic Author Message Miklos Post subject: RB 2009 v5 + mySQL + NewbiePosted: Wed Dec 02, 2009 4:39 am Joined: Wed Dec 02, 2009 4:28 am Posts: 2 Hi I'm brand new to RB (prof trial) and I am trying to learn slowly, but I'm completely stumped by this: in Open on window1 Code:window1.DatabaseQuery1.Database = test window1.DatabaseQuery1.SQLQuery = "SELECT * FROM products" window1.DatabaseQuery1.RunQuery This analyzes and compiles okay but when running it, it gives me a NilObjectException when reaching RunQuery. I added the db through the menu: Project->Add->Database->Select MySQL Community Server (values triple checked). Top Miklos Post subject: Re: RB 2009 v5 + mySQL + NewbiePosted: Wed Dec 02, 2009 10:06 am Joined: Wed Dec 02, 2009 4:28 am Posts: 2 Okay I got it working like this: Code:Dim db as MySQLCommunityServer db = New MySQLCommunityServer db.host="ip" db.port=3306 db.DatabaseName="test" db.UserName="user" db.Password="pas" if db.Connect then Dim i as Integer Dim rs as RecordSet rs = db.SQLSelect ("SELECT * FROM products") Listbox1.DeleteAllRows while not rs.eof Listbox1.AddRow "" for i = 1 to rs.FieldCount Listbox1.Cell( Listbox1.LastIndex, i-1 ) = rs.IdxField(i).StringValue next rs.MoveNext wend rs.Close else MsgBox "db failed" end if As someone new to RB and is looking upon the program with fresh eyes, this is simply not good enough. It should be doable with something along the lines of this: Code:Dim db as MySQLCommunityServer db = New MySQLCommunityServer DatabaseQuery1.Database = db DatabaseQuery1.RunQuery Listbox1.DataSource = DataControl1.RecordSet But can it be that to populate a listbox with your query result you have to do it manually cell by cell? that seems to me in lack of a better word - wrong. So far I've enjoyed using RB although the help could use code examples for a lot more entries, but this specific issue with populating a simple listbox with the sql query result seems to be an indicator that to properly use RB you have to spend more time doing tasks RB should do, rather than working on the app itself. Ohh well just an observation. Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 2 posts ] -- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
