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();
....

SqlType is giving me error.It says Sql Type does not exist

SqlDbType :)

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.

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.

Start over! did you try my piece of code? if you yes then tell me what's wrong else kindly check it.

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

Does reader.HasRows = false ?

nope

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.