|
-
February 16th, 2008, 04:15 AM
#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
-
February 17th, 2008, 05:28 PM
#2
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|