Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Syntax Trouble

Status
Not open for further replies.

liamba

Technical User
Jan 6, 2007
21
IE
Hi,
Im trying to read from a sql server database based on a date. The sql statement i believe is correct however it is the syntax at the end of the statement i believe is where the problem lies

protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
string date = Calendar1.SelectedDate.ToString();
PopulateGridview("SELECT [Competition_Time], [Competition_Day], [Competition_Date], [Competition_Name] FROM [tblTimeSheet] Where [Competition_Date] = + 'date' +);
}

Im not 100% sure how to write the + 'date" + section.
Any help would be great
 
I suppose this should help you out if you are using SQL Server:
and one more thing just try not to use variables as date because date is a keyword.. Well the below code should work.. Check it out

protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
string date = Calendar1.SelectedDate.ToString();
PopulateGridview("SELECT [Competition_Time], [Competition_Day], [Competition_Date], [Competition_Name] FROM [tblTimeSheet] Where [Competition_Date] ='" + date + "');
}

 
sorry quotes missing again..


suppose this should help you out if you are using SQL Server:
and one more thing just try not to use variables as date because date is a keyword.. Well the below code should work.. Check it out

protected void Calendar1_SelectionChanged(object sender, EventArgs e)
{
string date = Calendar1.SelectedDate.ToString();
PopulateGridview("SELECT [Competition_Time], [Competition_Day], [Competition_Date], [Competition_Name] FROM [tblTimeSheet] Where [Competition_Date] ='" + date + "')";
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top