Click here to Skip to main content
15,922,696 members
Home / Discussions / C#
   

C#

 
AnswerRe: Can anyone help me take a look at my code? Pin
Vikram A Punathambekar7-Dec-05 22:12
Vikram A Punathambekar7-Dec-05 22:12 
GeneralRe: Can anyone help me take a look at my code? Pin
momoo7-Dec-05 22:24
momoo7-Dec-05 22:24 
GeneralRe: Can anyone help me take a look at my code? Pin
Vikram A Punathambekar7-Dec-05 22:55
Vikram A Punathambekar7-Dec-05 22:55 
GeneralRe: Can anyone help me take a look at my code? Pin
J4amieC7-Dec-05 23:20
J4amieC7-Dec-05 23:20 
GeneralRe: Can anyone help me take a look at my code? Pin
Vikram A Punathambekar8-Dec-05 0:05
Vikram A Punathambekar8-Dec-05 0:05 
GeneralRe: Can anyone help me take a look at my code? Pin
J4amieC8-Dec-05 0:20
J4amieC8-Dec-05 0:20 
GeneralRe: Can anyone help me take a look at my code? Pin
Vikram A Punathambekar8-Dec-05 1:41
Vikram A Punathambekar8-Dec-05 1:41 
AnswerRe: Can anyone help me take a look at my code? Pin
J4amieC7-Dec-05 23:25
J4amieC7-Dec-05 23:25 
Hi, I can see from your code that when a user selects a date, you display it to him apsolutely 100% perfectly!! It will be formatted according to HIS/HER windows settings

This line is perfect!

TBDate1.Text = CAL1.SelectedDate.ToLongDateString();

However, take 1 step backwards:

DateTime selectedDateTime = CAL1.SelectedDate;

Without the .ToLongDateString() call, you have a DateTime Object.

The only place you went wrong below is that you tried to parse the string back into a Date, which at best is unnecessary and at worst will not work.

SqlConnection conn=new SqlConnection("my connection string");
SqlCommand cmd = conn.CreateCommand();
cmd.CommandText = "SELECT * FROM Particulars WHERE DateField = @Date";
cmd.Parameters.Add("@Date", SqlDbType.DateTime).Value = DateTime.Parse(TBDate1.Text);

The beauty of parameters (especially date ones) is that the ADO.NET provider will take care of any conversion for you... so change the last line to:

cmd.Parameters.Add("@Date", SqlDbType.DateTime).Value = CAL1.SelectedDate;

simple, huh?


GeneralRe: Can anyone help me take a look at my code? Pin
momoo8-Dec-05 14:05
momoo8-Dec-05 14:05 
Questionhwo to generate radom number with fixed seed? Pin
zhujp987-Dec-05 16:48
zhujp987-Dec-05 16:48 
AnswerRe: hwo to generate radom number with fixed seed? Pin
Vikram A Punathambekar7-Dec-05 17:47
Vikram A Punathambekar7-Dec-05 17:47 
QuestionWho do i include shell icons Pin
Garbast7-Dec-05 12:48
Garbast7-Dec-05 12:48 
AnswerRe: Who do i include shell icons Pin
Judah Gabriel Himango7-Dec-05 15:41
sponsorJudah Gabriel Himango7-Dec-05 15:41 
GeneralRe: Who do i include shell icons Pin
Garbast7-Dec-05 23:27
Garbast7-Dec-05 23:27 
QuestionGetting Selected Nodes from a Menu Pin
SeanCM7-Dec-05 12:20
SeanCM7-Dec-05 12:20 
AnswerRe: Getting Selected Nodes from a Menu Pin
Curtis Schlak.7-Dec-05 12:33
Curtis Schlak.7-Dec-05 12:33 
AnswerRe: Getting Selected Nodes from a Menu Pin
Curtis Schlak.7-Dec-05 12:36
Curtis Schlak.7-Dec-05 12:36 
GeneralRe: Getting Selected Nodes from a Menu Pin
SeanCM7-Dec-05 13:29
SeanCM7-Dec-05 13:29 
GeneralRe: Getting Selected Nodes from a Menu Pin
Curtis Schlak.8-Dec-05 2:23
Curtis Schlak.8-Dec-05 2:23 
QuestionBinary file serializaton Pin
Noon147-Dec-05 12:03
Noon147-Dec-05 12:03 
AnswerRe: Binary file serializaton Pin
leppie7-Dec-05 22:53
leppie7-Dec-05 22:53 
GeneralRe: Binary file serializaton Pin
Noon148-Dec-05 1:41
Noon148-Dec-05 1:41 
QuestionReload apllication Pin
RobertoTjMx7-Dec-05 11:40
RobertoTjMx7-Dec-05 11:40 
AnswerRe: Reload apllication Pin
Judah Gabriel Himango7-Dec-05 12:44
sponsorJudah Gabriel Himango7-Dec-05 12:44 
QuestionC# Flash Player Detection Pin
radnix7-Dec-05 11:34
radnix7-Dec-05 11:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.