• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 173
  • Last Modified:

Select statement not working

Hello experts,

I am new to the Delphi/ASP.net so please bear with me. I an using Delphi 2006 and have a webfom with datagrid in it.  I am able to display data in the datagrid from a table but when I add a text box and try to display  only the records where table1.Field1 = TextBox.Text, I still get all the rows in the table.  Can u please let me know how I can fix the code below:

procedure TWebForm1.Button1_Click(sender: System.Object; e: System.EventArgs);
var
  EMPNo: String;
  command: BdpCommand;
  I : integer;
begin

  bdpDataAdapter1.Active := False;
  command := BdpCommand.Create;
  command.Connection := bdpConnection1;
  bdpConnection1.Open;
  command.CommandText := 'Select * FROM Table1  ' +
    'WHERE Field1 = ''' + textbox1.text+ '''';
  try
     command.Executereader ;
  except
    on E: Exception do
      Response.Write(E.Message)
  end;
  bdpDataAdapter1.Active := True;
  dataGrid1.DataBind // refresh data
end;


0
kalamoun
Asked:
kalamoun
1 Solution
 
BlackTigerXCommented:
you are never conecting the dataadapter to the command you are running
0
 
kalamounAuthor Commented:
Thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now