Gambas from LXF71

The place to post if you need help or advice

Moderators: ChrisThornett, LXF moderators

Gambas from LXF71

Postby mpie » Mon Aug 29, 2005 7:12 am

Hi peoples
Been working mt way through the gambas tutorial in lxf71, and have cross referenced the code many times and I can't see any diffs

I was wondering if maybe there is an error is the sql used as it is complaining that the result is not available and highlighting this section marked with asterixs.

PUBLIC SUB ComboBox1_Click()

DIM res AS Result
DIM sql AS String
resManager.MoveFirst
resManager.MoveTo(ComboBox1.Index)
sql = " select city from office" & ********
"where manager_id=.id" & resManager!id
res = conn.Exec(sql)
TextBox1.Text = res!city
END
would be grateful to know if anyone else has tried ths or if they can see an error
mpie
 
Posts: 8
Joined: Mon Aug 29, 2005 6:43 am

RE: Gambas from LXF71

Postby nordle » Mon Aug 29, 2005 1:39 pm

sql = "select city from office " &
"where manager_id=" & resManager!id

You had an extra id in there, and also, there needs to be a space between office and where otherwise when the string is formed it becomes officewhere, I also removed a space before the select.
Last edited by nordle on Mon Aug 29, 2005 1:43 pm, edited 1 time in total.
User avatar
nordle
LXF regular
 
Posts: 1500
Joined: Fri Apr 08, 2005 9:56 pm

RE: Gambas from LXF71

Postby mpie » Mon Aug 29, 2005 1:40 pm

der.......

(head in bucket of sand1!) :oops:



still no worky.... any other idea's
mpie
 
Posts: 8
Joined: Mon Aug 29, 2005 6:43 am

Re: RE: Gambas from LXF71

Postby nordle » Mon Aug 29, 2005 1:44 pm

mpie wrote:der.......

(head in bucket of sand1!) :oops:


Sorry mpie, I edited my response to include a bit more detail, but that crossed over with your post :)
User avatar
nordle
LXF regular
 
Posts: 1500
Joined: Fri Apr 08, 2005 9:56 pm

RE: Re: RE: Gambas from LXF71

Postby mpie » Mon Aug 29, 2005 1:53 pm

nope now look like this...

PUBLIC SUB ComboBox1_Click()

DIM res AS Result
DIM sql AS String
resManager.MoveFirst
resManager.MoveTo(ComboBox1.Index)
sql = "select city from office" &
"where manager_id=" & resManager!id
res = conn.Exec(sql)
TextBox1.Text = res!city
END :?:

I'm miffed
mpie
 
Posts: 8
Joined: Mon Aug 29, 2005 6:43 am

RE: Re: RE: Gambas from LXF71

Postby nordle » Mon Aug 29, 2005 2:02 pm

But as mentioned, what you've posted does not have a space after office OR infront of where, unless my eyesite is failing me again :)
eg
sql = "select city from office " &
"where manager_id=" & resManager!id

Or is that now not the problem, is it failing at a different point, even so its worth changing it if not already.
I think, therefore I compile
User avatar
nordle
LXF regular
 
Posts: 1500
Joined: Fri Apr 08, 2005 9:56 pm

RE: Re: RE: Gambas from LXF71

Postby mpie » Mon Aug 29, 2005 2:21 pm

still failing sam point even with white space,
this is what mysqldump gives....
[mike@Atlantis ~]$ mysqldump --user=root -p customers
Enter password:
-- MySQL dump 10.9
--
-- Host: localhost Database: customers
-- ------------------------------------------------------
-- Server version 4.1.13

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `manager`
--

DROP TABLE IF EXISTS `manager`;
CREATE TABLE `manager` (
`id` int(11) NOT NULL auto_increment,
`surname` varchar(50) collate latin1_general_ci default NULL,
`firstname` varchar(50) collate latin1_general_ci default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

--
-- Dumping data for table `manager`
--


/*!40000 ALTER TABLE `manager` DISABLE KEYS */;
LOCK TABLES `manager` WRITE;
UNLOCK TABLES;
/*!40000 ALTER TABLE `manager` ENABLE KEYS */;

--
-- Table structure for table `office`
--

DROP TABLE IF EXISTS `office`;
CREATE TABLE `office` (
`id` int(11) NOT NULL auto_increment,
`city` varchar(50) collate latin1_general_ci default NULL,
`manager_id` int(11) default NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

--
-- Dumping data for table `office`
--


/*!40000 ALTER TABLE `office` DISABLE KEYS */;
LOCK TABLES `office` WRITE;
UNLOCK TABLES;
/*!40000 ALTER TABLE `office` ENABLE KEYS */;

/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

[mike@Atlantis ~]$


so all the elements are there from what i can see yet fails to get a result??
mpie
 
Posts: 8
Joined: Mon Aug 29, 2005 6:43 am

RE: Re: RE: Gambas from LXF71

Postby nordle » Mon Aug 29, 2005 2:28 pm

Is it worth just trying the SQL statement in a mysql shell, just to make sure you do get a result?

I can't remember the exact method, something like
mysql -u username -p
use database_name
select city from office where manager_id is not null;
User avatar
nordle
LXF regular
 
Posts: 1500
Joined: Fri Apr 08, 2005 9:56 pm

RE: Re: RE: Gambas from LXF71

Postby mpie » Mon Aug 29, 2005 2:30 pm

AAAAHHHHH is see........


yup that will do it every time, city exists but comtains no info, I really feel a fool...... :shock:
mpie
 
Posts: 8
Joined: Mon Aug 29, 2005 6:43 am

Re: RE: Re: RE: Gambas from LXF71

Postby nordle » Mon Aug 29, 2005 2:39 pm

mpie wrote:AAAAHHHHH is see........


yup that will do it every time, city exists but comtains no info


good to hear that it's sorted :)
User avatar
nordle
LXF regular
 
Posts: 1500
Joined: Fri Apr 08, 2005 9:56 pm

RE: Re: RE: Re: RE: Gambas from LXF71

Postby mpie » Mon Aug 29, 2005 2:41 pm

if only it had form a terminal output is

Database changed
mysql> select city from office where manager_id=3 :
-> select city from office where manager_id=3 ;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':
select city from office where manager_id=3' at line 1
mysql> select city from office where manager_id=3 ;
+----------+
| city |
+----------+
| New York |
+----------+
1 row in set (0.00 sec)

mysql>

but still failing in gamabs



thanks for this btw
:D
mpie
 
Posts: 8
Joined: Mon Aug 29, 2005 6:43 am

RE: Re: RE: Re: RE: Gambas from LXF71

Postby mpie » Sat Sep 03, 2005 1:43 pm

question what version of mysql was used as even if i use the form that was on the dvd I get

error Syntax incorrect near !id

then the app fails and highlights the res =conn.Exec(sql) line


resManager.MoveTo(ComboBox1.Index)
sql = "select city from office" &
"where manager_id=" & resManager!id
res = conn.Exec(sql) ********
mpie
 
Posts: 8
Joined: Mon Aug 29, 2005 6:43 am


Return to Help!

Who is online

Users browsing this forum: Bing [Bot] and 2 guests