Hi, I need some suggestions...
I have created a form in visual studio 2005 in which a user chooses between two dates. I placed two dateTimePickers and a View Button. When the user clicks the view button, I have a sql command that is supposed to retrieve all values from both table 'Guest' and table 'Sales' in sql server 2005.
My code looks like this:
(c-sharp)
My obvious problem here is that since I want all values from both tables, I don't know what other process I should use. For example:
textBox1.Text = dt.Rows[0][0].ToString(); will not work because it will only return the number of rows...The other problem is that I have tested the function with actual dates and it works fine, so it has something to do with dateTimePickers 1.Text or something else...I would really appreciate some suggestions as to how to obtains all values and details found on those two tables between those two dates and on what would be the easiest way to display it. Thanks. Any input as to obtain all the values will be greatly appreaciated...
--GM
I have created a form in visual studio 2005 in which a user chooses between two dates. I placed two dateTimePickers and a View Button. When the user clicks the view button, I have a sql command that is supposed to retrieve all values from both table 'Guest' and table 'Sales' in sql server 2005.
My code looks like this:
(c-sharp)
Code:
SqlConnection dbConnection = new SqlConnection(xmldb);
SqlCommand cmd = new SqlCommand(" SELECT * From Guest g, Sales s Where s.Date >= '" + dateTimePicker1.Value + "' And s.Date <= '" + dateTimePicker2.Value + "' Order By s.Date ", dbConnection1);
cmd.CommandType = CommandType.Text;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
textBox1.Text = dt.Rows[0][0].ToString();
textBox1.Text = dt.Rows[0][0].ToString(); will not work because it will only return the number of rows...The other problem is that I have tested the function with actual dates and it works fine, so it has something to do with dateTimePickers 1.Text or something else...I would really appreciate some suggestions as to how to obtains all values and details found on those two tables between those two dates and on what would be the easiest way to display it. Thanks. Any input as to obtain all the values will be greatly appreaciated...
--GM
Comment