?
Solved

simple dbexpress query question.

Posted on 2003-04-01
4
Medium Priority
?
214 Views
Last Modified: 2010-04-06
I'm currently teaching myself Kylix/Delphi, and am trying to do some stuff with a MySQL DB.  I am able to use the SQLQuery component to do inserts and updates so far, but something I need to do right now is get some information from a select statement.  Actually a very simple one:  "SELECT (count(id)+1) FROM messages"

creating the component with the SQL is simple, I am unsure how to retrieve the results though, I want it back as a simple string.
0
Comment
Question by:Blixem
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 10

Expert Comment

by:kacor
ID: 8248451
Could you explain your question a little bit better by an example?
wbr
Janos
0
 
LVL 12

Accepted Solution

by:
esoftbg earned 400 total points
ID: 8249055
var
  I: Integer;
  S: string;
begin
  if Query.Active then
    Query.CLose;
  Query.SQL.Text := 'SELECT (count(id)+1) COUNT_ID FROM messages';
  Query.Open;
// result is:
  I := Query.FieldByName('COUNT_ID').AsInteger;
// or result is:
  S := Query.FieldByName('COUNT_ID').AsString;
end;
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 8251416
you can also use

Query.Fields[0].AsYouWantHere;
0
 

Author Comment

by:Blixem
ID: 8251522
Exactly what I was looking for, thanks both of ya!
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month14 days, 22 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question