Hi Guys ,
i am trying to connect date time picker to database.So what i am trying to do is when user select a date in the datretime picker ,it should display all the words added on that particular day.Can anyone help me with this.Thanks

SELECT words FROM TableWords WHERE date = @date
SqlConnection dbConnection = new SqlConnection(CONNECTION_STRING);
string commandString = 
            "SELECT words FROM TableWords WHERE date = @date";
             SqlCommand commandStatement = new SqlCommand(commandString, dbConnection);
            commandStatement.Parameters.Add("@date", SqlType.SmallDatetime).Value = DateTimePicker1.Value;
DataReader results = commandStatement.ExecuteReader();
....

this doesnt work for me.The query work but it doesnt pull any record. the i am inserting data is

myString = @"INSERT INTO wordTbl(word,text,date)  Values('" + (string)row["word"] + "','" + richTextBox1.Text + "','" + DateTime.Now.ToString("yyyyMMdd hh:mm:ss:fff") + "')";

i need to now how to pull this according to the selected date in datetime picker.
thanks

It's another question, isn't it? please if thread question answered mark it as solved and open another thread.
Consistency Required :)

no its the same question , its just that your solution didnt worked for me.Thanks

You use Insert command and need to Pull data?! How come?!
Can you please tell me after changing SqlDbType what errors raised.

Edited 6 Years Ago by Ramy Mahrous: n/a

what i said is that to inser date and time i used the above statement, now i need to select the words which were eneterd on the date selected in datepicker and thats what is not working.

yes i did tyr, it doesnt give me any error but it doesnt fetch any data either, eventhough i know i do have data with todays date.just to let you knw i even have time stored in the databse, do u think that might be the issue

This article has been dead for over six months. Start a new discussion instead.