0

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

2
Contributors
12
Replies
13
Views
7 Years
Discussion Span
Last Post by sdhawan
0
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();
....
0

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

0

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

0

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

0

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

Edited by Ramy Mahrous: n/a

0

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.

0

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 topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.