CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2008
    Posts
    1

    Searching operation in datatable

    Hi all,

    I want to search a particular row from a datatable and display it on a datagrid.Am using sql queries to insert, update and in the same way am using select query to do search operation. The statements i have written are like this(am using cldb dll)

    private void Search_Click(object sender, System.EventArgs e)
    {
    ds = clDb.oDb.executeDataSet("Mydatabase","SELECT * FROM Books WHERE '"+listBox1.SelectedItem.ToString()+"' = '"+searchtxtbx.Text+"'");
    dataGrid1.DataSource = ds;
    dataGrid1.DataMember = ds.Tables[0].ToString();
    }
    when i click on the serach button, it is displaying nothing on the datagrid. can anyone pls tel me where i have done the mistake.

    Thanks in advance

  2. #2
    Join Date
    Nov 2002
    Location
    .NET 3.5 VS2008
    Posts
    1,039

    Re: Searching operation in datatable

    Code:
    dataGrid1.DataMember = ds.Tables[0].ToString();
    I think the DataMember should reference a field/column in your database table and not the table name which is what you're doing. It's not clear what development environment you're using but I would suggest using the designer to set up such properties including the actual datasource. You can read about Object data sources in MSDN.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured