一个TDataBase,一个TQuery在加几个BUTTON和EDIT应该足够了

解决方案 »

  1.   

    使用ADO进行数据库的操作:
    1、使用ADOConnection连接数据库
    2、使用ADOQuery连接ADOConnection
    3、类似的在触发查询的代码中写入以下的代码:
    ADOQuery.Close;
    ADOQuery.SQL.Clear;
    ADOQuery.SQL.Add( 'Select * From Table Where UserName = ''' + EditName.Text + '''' );
    Try
    ADOQuery.Open;
    Except
    End;
      

  2.   

    ADOConnection1: TADOConnection;
        ADOCommand1: TADOCommand;
        ADOQuery1: TADOQuery;
     
     if ADOConnection1.Connected then
      begin
        with ADOCommand1 do
        begin
          try
            Connection := ADOConnection1;
            CommandText := '';
            CommandText := 'Update t_config set start_ip_addr =:start_ip,end_ip_addr =:end_ip';
            Parameters.ParamByName('start_ip').Value := StartIPString;
            Parameters.ParamByName('end_ip').Value := EndIPString;
            Execute;
          finally
          end;
        end;
      end;使用SQL动态参数来解决。Delphi_Li(Delphi Li) :
    你的这句:
    ADOQuery.SQL.Add( 'Select * From Table Where UserName = ''' + EditName.Text + '''' );
    可能不行罢?你的'''会被解释成为'' '你编译过没有?应该编译不过的。
      

  3.   

    query1.close;
    query1.sql.clear
    query1.sql.add(format('select * from yourtabel where key=%d' ,[edit1.text]));
    query1.open;