Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Delphi Databases > Re: SQL won't w...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 10 of 24 Topic 944 of 988
Post > Topic >>

Re: SQL won't work

by "pr" <pr@[EMAIL PROTECTED] > Nov 2, 2006 at 03:19 PM

"Greg Gailer" <g_gailer@[EMAIL PROTECTED]
> wrote in message 
news:12kjkbjp6q4ne30@[EMAIL PROTECTED]
> Dodgy wrote:
>> On Fri, 27 Oct 2006 13:13:50 +1000, Greg Gailer
>> <g_gailer@[EMAIL PROTECTED]
> waffled on about something:
>>
>>> Dodgy wrote:
>>>> On Thu, 26 Oct 2006 19:56:48 +1000, Greg Gailer
>>>> <g_gailer@[EMAIL PROTECTED]
> waffled on about something:
>>>>
>>>>> Dodgy wrote:
>>>>>> On Thu, 26 Oct 2006 16:44:52 +1000, Greg Gailer
>>>>>> <g_gailer@[EMAIL PROTECTED]
> waffled on about something:
>>>>>>
>>>>>>> Greetings all,
>>>>>>> I have a MySQL database running on a Linux server and wanting to 
>>>>>>> access it from Windows. I have the database connection all working

>>>>>>> correctly. I am using the tables and the query from the BDE 
>>>>>>> components and can edit the database perfectly through the tables 
>>>>>>> but am having no success in the code for the query. The query 
>>>>>>> component has a basic query that works well in the component
itself.
>>>>>>>
>>>>>>> select * from Service
>>>>>>> order by CustNum,Invoice;
>>>>>>>
>>>>>>> In code, I execute another query to isolate just one person as 
>>>>>>> follows:
>>>>>>>
>>>>>>> with Query do begin
>>>>>>>   if Active then Close;
>>>>>>>   if Prepared then Unprepare;
>>>>>>>   SQL.Clear;
>>>>>>>   SQL.Add('select * from Service');
>>>>>>>   SQL.Add('where CustNum=9');
>>>>>>>   SQL.Add('order by Invoice;');
>>>>>>>   Prepare;
>>>>>>>   Open;
>>>>>>>       end;
>>>>>>>
>>>>>>> I was hoping to get all the records for customer number 9 from
this 
>>>>>>> query but I get the records of all customers ordered as before.
This 
>>>>>>> seems to suggest that the query is not working at all. I have used

>>>>>>> this sort of query before for local DBase files with no problems. 
>>>>>>> What am I doing wrong now? Can anyone please help?
>>>>>>> Greg
>>>>>>> g_gailer@[EMAIL PROTECTED]
>>>>>> I must confess to never having used the Tstring methods of the SQL
>>>>>> property, and as your query seems to be acting as if only the first
>>>>>> line is being executed, that's the first thing that comes to my
>>>>>> attention.
>>>>>>
>>>>>> Have you tried...
>>>>>>
>>>>>> with Query do begin
>>>>>>   if Active then Close;
>>>>>>   SQL.text:='select * from Service '
>>>>>>   +'where CustNum=9 '
>>>>>>   +'order by Invoice;');
>>>>>>   Open;
>>>>>> end;
>>>>>>
>>>>>> Dodgy.
>>>>> Thanks for the reply,
>>>>> I tried what you suggested and it still doesn't work. It should, as 
>>>>> far as I know, send the query when I close and then open the query
but 
>>>>> it doesn't seem to be doing it from the code. It does , however, do
it 
>>>>> from the actual component, so I must be missing something in my
code. 
>>>>> I am very confused!
>>>>>
>>>>> Greg
>>>> You don't say what query component you are using.
>>>>
>>>> Oh hang on, I just saw an acronym I missed earlier.
>>>>
>>>> You said "BDE"
>>>>
>>>> I should have run away screaming at that point...
>>>>
>>>> Dump it... Loose it... It never caused me anything but trouble.
>>>>
>>>> Use standard TADOConnection and TADOQuery (Came in D5 and later I
>>>> believe).
>>>>
>>>> TADOConnection will happily connect to the MySQL ODBC connector.
(IIRC
>>>> Just don't give it an initial catalogue).
>>>>
>>>> Dodgy.
>>> Well, that was a good thought. I changed the query as you said. I 
>>> dropped a TADOConnection, got it to connect, used a TADOQuery, 
>>> DatasetProvider, ClientDataset and then a DataSource on the form. 
>>> Connected them all together and checked that my basic SQL was working 
>>> again and then tried the code again. Still no success I'm afraid. Is 
>>> there anything else that can stop the query from accessing the
database? 
>>> It seems like the basic component SQL statement is working but the
code 
>>> isn't. There must be something disabling the query.
>>> Greg
>>
>> Did you see pr's comment about you having a semi-colon on the end of
>> your sql query? I didn't even see it at first, so I even ended up with
>> it pasted into my code!
>>
>> Try
>>    SQL.text:='select * from Service '
>>    +'where CustNum=9 '
>>    +'order by Invoice');
>>
>> Dodgy.
>
> I have tried it with and without the semicolon but neither works. I have

> tried both SQL.Text and SQL.Add. I have tried BDE, dbExpress, dbGo 
> components and the trial version of mySQLDAC and they all do the same 
> thing. It looks to me now like nothing can access the database correctly

> so I will try in Visual Basic and see how that goes. Thanks for your
help 
> and your time.

I you have tried all of these then it is unlikely that VB will make it
work.
You need to look at some of the more esoteric things:
-Are field and table names case sensitive? This may depend on the tool
used.
-Field types, maybe the values are cast and then don't work properly.
-Maybe you are working on the wrong query, the wrong datamodule?
-Maybe you reassign datasources in code?
-What events are involved when opening the query?
-Filters?
etc.

PR
 




 24 Posts in Topic:
SQL won't work
Greg Gailer <g_gailer@  2006-10-26 16:44:52 
Re: SQL won't work
Dodgy <Dodgy@[EMAIL PR  2006-10-26 09:45:53 
Re: SQL won't work
Greg Gailer <g_gailer@  2006-10-26 19:56:48 
Re: SQL won't work
"pr" <pr@[EM  2006-10-26 12:34:08 
Re: SQL won't work
Dodgy <Dodgy@[EMAIL PR  2006-10-26 14:10:29 
Re: SQL won't work
Dodgy <Dodgy@[EMAIL PR  2006-10-26 14:09:18 
Re: SQL won't work
Greg Gailer <g_gailer@  2006-10-27 13:13:50 
Re: SQL won't work
Dodgy <Dodgy@[EMAIL PR  2006-10-31 10:58:18 
Re: SQL won't work
Greg Gailer <g_gailer@  2006-11-02 22:07:13 
Re: SQL won't work
"pr" <pr@[EM  2006-11-02 15:19:14 
Re: SQL won't work
"Ray Porter" &l  2006-11-02 22:40:54 
Re: SQL won't work
Greg Gailer <g_gailer@  2006-11-03 16:54:21 
Re: SQL won't work
Dan <Doculus at CMDCs  2006-10-26 18:56:24 
Re: SQL won't work
Greg Gailer <g_gailer@  2006-10-27 13:06:05 
Re: SQL won't work
"pr" <pr@[EM  2006-10-27 14:56:14 
Re: SQL won't work
Greg Gailer <g_gailer@  2006-10-28 09:49:20 
Re: SQL won't work
Dan <Doculus at CMDCs  2006-10-29 09:21:15 
Re: SQL won't work
Greg Gailer <g_gailer@  2006-11-02 22:10:46 
Re: SQL won't work
"Philip" <re  2006-11-02 15:08:46 
Re: SQL won't work
Greg Gailer <g_gailer@  2006-11-03 16:13:22 
Re: SQL won't work
"Philip" <re  2006-11-03 07:22:22 
Re: SQL won't work
"Philip" <re  2006-11-03 07:23:43 
Re: SQL won't work
Greg Gailer <g_gailer@  2006-11-04 11:58:40 
Re: SQL won't work
"Ray Porter" &l  2006-11-05 08:30:57 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Oct 12 10:28:38 CDT 2008.