E eggese Unregistered / Unconfirmed GUEST, unregistred user! 2003-04-18 #1 select语句中变量怎样用? 谢谢!我是初学者!:(
L lmeiing Unregistered / Unconfirmed GUEST, unregistred user! 2003-04-18 #2 with ADOCommand1do begin CommandText := 'INSERT INTO Talley ' + '(Counter) ' + 'VALUES NewValueParam)'; CommandType := cmdText; Parameters.ParamByName('NewValueParam').Value := 57; Execute end;
with ADOCommand1do begin CommandText := 'INSERT INTO Talley ' + '(Counter) ' + 'VALUES NewValueParam)'; CommandType := cmdText; Parameters.ParamByName('NewValueParam').Value := 57; Execute end;
H HunterTeam Unregistered / Unconfirmed GUEST, unregistred user! 2003-04-18 #3 应区分字段类型,如果是字符串型,应加'号,由于Delphi是'号之前要另加一个'号作前导, 才能认定是一个'号,比如a'b要写成'a''b',所以关于这一点要小心。 字符串型: sql.text:='select * from tablename where sField='''+字符串变量+''''; 数值型: sql.text:='select * from tablename where nField='+数值变量;
应区分字段类型,如果是字符串型,应加'号,由于Delphi是'号之前要另加一个'号作前导, 才能认定是一个'号,比如a'b要写成'a''b',所以关于这一点要小心。 字符串型: sql.text:='select * from tablename where sField='''+字符串变量+''''; 数值型: sql.text:='select * from tablename where nField='+数值变量;
H humanc2d4 Unregistered / Unconfirmed GUEST, unregistred user! 2003-04-18 #5 一般查询:select * from tablename where sField='''+字符串变量+''' 模糊查询:select * from tablename where sField like ''%'+字符串变量+'%''
一般查询:select * from tablename where sField='''+字符串变量+''' 模糊查询:select * from tablename where sField like ''%'+字符串变量+'%''
E eggese Unregistered / Unconfirmed GUEST, unregistred user! 2003-04-18 #6 谢谢大家的帮助!!谢谢![gold][/gold][]