相当于 sql.add('SELECT 年龄,性别 FROM 表 where name = '''+combobox1.text+''' ')
ADOQuery.Close; ADOQuery.SQL.Text:='select 姓名,年龄,性别 from 表名 where 姓名="'+ComboBox.text+'"'; ADOQuery.Open; Lable.Caption:=ADOQuery.FieldByName('年龄').AsString; Edit.Text:=ADOQuery.FieldByName('性别).AsString; 这样写的话没有问题 按上述的话 会报错 是不是我还有什么地方没有设置好 还是
引号有问题。 ADOQuery.SQL.Text:='select 姓名,年龄,性别 from 表名 where 姓名="'+ComboBox.text+'"'; 应该是 ADOQuery.SQL.Text:='select 姓名,年龄,性别 from 表名 where 姓名='''+ComboBox.text+'''';
不是设置好,是查询的连接字符串 with ADOQuery do begin Acitve:=False; SQL.Text:='SELECT 姓名,年龄,性别 FROM 表名 WHERE 姓名='''+ComboBox.Text+''''; Active:=True; Label.Caption:=FieldByName('年龄').AsString; Edit1.Text:=FieldByName('性别').AsString; end;你在试试
begin
active := false;
SQL.TEXT := 'SELECT 年龄,性别 FROM 表 where name = '''+combobox1.text+''' '
active := true;
label.caption:= fieldbyname('年龄').asstring;
edit1.text := fieldbyname('性别').asstring;
end;
2.把年龄,性别等,也添加到combobox中,用AddObject方法
sql.add('SELECT 年龄,性别 FROM 表 where name = '''+combobox1.text+''' ')
ADOQuery.SQL.Text:='select 姓名,年龄,性别 from 表名 where 姓名="'+ComboBox.text+'"';
ADOQuery.Open;
Lable.Caption:=ADOQuery.FieldByName('年龄').AsString;
Edit.Text:=ADOQuery.FieldByName('性别).AsString; 这样写的话没有问题
按上述的话 会报错 是不是我还有什么地方没有设置好 还是
ADOQuery.SQL.Text:='select 姓名,年龄,性别 from 表名 where 姓名="'+ComboBox.text+'"';
应该是
ADOQuery.SQL.Text:='select 姓名,年龄,性别 from 表名 where 姓名='''+ComboBox.text+'''';
with ADOQuery do begin
Acitve:=False;
SQL.Text:='SELECT 姓名,年龄,性别 FROM 表名 WHERE 姓名='''+ComboBox.Text+'''';
Active:=True;
Label.Caption:=FieldByName('年龄').AsString;
Edit1.Text:=FieldByName('性别').AsString;
end;你在试试