Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

SQL Problem

Posted on 1999-06-27
8
Medium Priority
?
150 Views
Last Modified: 2010-04-06
i have a table made in the database desktop in paradox7 with the fallowing fields:
1  Id_produto        autoincrement  index
2  Desig         Alpha 20
3  P_compra      Number
4  Cod_iva           Number
5  Estado      Number
6  Utente      Number
7  Total      Number
8  S_actual      Number
9  S_medio      Number
10 S_minimo      Number
11 Cod_forn      Number

i have a secondary index on Desig called PorNome

Now what is wrong with this???
It compiles but when i fill the fields with the fallowing data:
aspirina
200
1
1000
210
1210
100
50
10
1
it raises an exception saying invalid field aspirina.

sql:= 'INSERT INTO produtos(Desig,P_compra,Cod_iva,';
sql:= sql + 'Estado,Utente,Total,';
sql:= sql + 'S_actual,S_medio,S_minimo,Cod_forn)';
sql:= sql + 'VALUES(';
sql:= sql + E_P_Des.text + ',';
sql:= sql + E_P_Compra.text + ',';
sql:= sql + E_P_Iva.text + ',';
sql:= sql + E_P_Estado.text + ',';
sql:= sql + E_P_Utente.text + ',';
sql:= sql + E_P_Total.text + ',';
sql:= sql + E_P_SActual.text + ',';
sql:= sql + E_P_SMedio.text + ',';
sql:= sql + E_P_SMinimo.text + ',';
sql:= sql + inttostr(Cod_Fornecedor) + ')';
query1.SQL.Add(sql);
query1.ExecSQL;

Please Help me!!!
Thanks
0
Comment
Question by:ElvasLion
[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
  • 2
  • 2
8 Comments
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 150 total points
ID: 1384848
I think you need to put quotes around the string value.

Try changing this:

sql:= sql + E_P_Des.text + ',';

to this:

sql:= sql + QuoedStr(E_P_Des.text) + ',';

Cheers,

Raymond.

0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1384849
Oops:

sql:= sql + QuotedStr(E_P_Des.text) + ',';

Cheers,

Raymond.

0
 
LVL 15

Expert Comment

by:simonet
ID: 1384850
Olá ElvasLion,

Como vão as coisas aí em Portugal?

O erro pode estar acontecendo porque já havia um outro SQL statement antes de você chamar:

>query1.SQL.Add(sql);
>query1.ExecSQL;

O melhor a se fazer neste case é ter certeza que TQuery.SQL está limpo antes de se adicionar um novo statement:

Query1.SQL.clear;
Query1.SQL.add(SQL);
Query1.execute;

Além disto, a sugestão do Raymond também pode estar correta. Todo valor tipo String tem que estar entre aspas (").

Yours,

Alex
Athena's Place: http://www.bhnet.com.br/~simonet
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:ElvasLion
ID: 1384851
Thanks raymond you´re answer hit just the spot.

0
 
LVL 1

Author Comment

by:ElvasLion
ID: 1384852
Oi alex és brasileiro???
Podes não acreditar mas eu vinha mesmo agora fazer uma pergunta, uma vex queestava a utilizar a query1 para fazer vários updates seguidos e não conseguia encontrar a propriedade que limpava a query. mto obrigado, mas neste caso tenho de dar os pontos ao raymond pois a resposta dele foi a correcta para aquela pergunta.
se me quiseres contactar aqui fica o meu email
rdd16793@mail.telepac.pt
um abraço.
0
 
LVL 1

Author Comment

by:ElvasLion
ID: 1384853
Oi alex és brasileiro???
Podes não acreditar mas eu vinha mesmo agora fazer uma pergunta, uma vex queestava a utilizar a query1 para fazer vários updates seguidos e não conseguia encontrar a propriedade que limpava a query. mto obrigado, mas neste caso tenho de dar os pontos ao raymond pois a resposta dele foi a correcta para aquela pergunta.
se me quiseres contactar aqui fica o meu email
rdd16793@mail.telepac.pt
um abraço.
0
 
LVL 15

Expert Comment

by:simonet
ID: 1384854
Sim, sou brasileiro, de Belo Horizonte, estado de Minas Gerais. De que parte de Portugal você é?

Abraços,

Alex



0
 
LVL 1

Author Comment

by:ElvasLion
ID: 1384855
ELvas a 200 Km de Lisboa e a 11 Km de Badajoz(Espanha)!!
Já agora vê-lá se me podes ajudar na pergunta nova que fiz, é que tenho uma semana para aprender delphi e realizar um programa pois não o querem em vb!!!!
Um Abraço
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
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…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

715 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