Reputation: 33
ds.Tables.Add(dt);
da = new SqlDataAdapter(
@"select Time1, Time2, EndDate from Event
where Venue ='" + txtVenue.Text + "',
StartDate ='" + cbStartMonth.Text + "/" +
cbStartDay.Text + "/" +
DateTime.Today.Year + "'" ,conn);
da.Fill(dt);
i'm sorry for the confusion, the code actually works but the problem is now how to view data coming from the data table
Upvotes: 1
Views: 25259
Reputation: 537
I would also change your code to use parameters. Otherwise you are leaving yourself open for serious SQL injection attacks all over the place.
Look here for an example of how to use parameters with your SqlDataAdapter. http://msdn.microsoft.com/en-us/library/bbw6zyha(v=vs.71).aspx
It also answers your question.
HTH SR
Upvotes: 0
Reputation: 21897
A DataSet
is a collection of DataTable
s. You don't convert from one to the other, one stores the other.
If only 1 row is showing up, then your Sql
is only returning a single row.
Upvotes: 2
Reputation: 29000
Just you adjust with .Tables property
var result = yourDataSet.Tables[0];
Your table is empty because you can adjust your query with and between clauses
But you rewrite your query ( You add and operator)
da = new SqlDataAdapter("select Time1, Time2, EndDate from Event
where Venue ='" + txtVenue.Text + "' AND
StartDate ='" + cbStartMonth.Text + "/" +
cbStartDay.Text + "/" +
DateTime.Today.Year + "'" ,conn);
Upvotes: 1