Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
SqlDataAdapter cmd = new SqlDataAdapter("select * from calender where date= " + monthCalendar1.SelectionRange.Start , con);
            
            SqlCommandBuilder cb = new SqlCommandBuilder(cmd);
            DataSet ds = new DataSet();
            cmd.Fill(ds);


            dataGridView1.DataSource = ds.Tables[0];



can solve this problem to show the information when select the date from calender
Posted
Updated 16-Nov-12 12:01pm
v2
Comments
DinoRondelly 16-Nov-12 17:56pm    
What type of field is date?
is it a datetime field?

thanks sooooooo much it solved
 
Share this answer
 
thanks it give me this problem

Conversion failed when converting datetime from character string.
 
Share this answer
 
Comments
Rohit Shrivastava 16-Nov-12 18:46pm    
use convert method to convert string to datetime updated the solution.
Change

C#
SqlDataAdapter cmd = new SqlDataAdapter("select * from calender where date= " + monthCalendar1.SelectionRange.Start , con);

to
C#
SqlDataAdapter cmd = new SqlDataAdapter("select * from calender where date= CAST('" + monthCalendar1.SelectionRange.Start.ToString() + "' as datetime)" , con);


please refer http://msdn.microsoft.com/en-us/library/ms187928.aspx[^] to cast string to datetime for more parameters.
I would suggest to use parameters. You can find many samples for creating command with parameters.

Hope this helps.
 
Share this answer
 
v4
Comments
Maciej Los 16-Nov-12 18:03pm    
It might works! +5
Manoj Kumar Choubey 16-Nov-12 23:26pm    
+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900