Click here to Skip to main content
15,917,061 members
Home / Discussions / C#
   

C#

 
Generalserialization Pin
cristina_tudor11-May-04 10:15
cristina_tudor11-May-04 10:15 
GeneralRe: serialization Pin
Heath Stewart11-May-04 11:04
protectorHeath Stewart11-May-04 11:04 
GeneralQuery, DateTime Pin
DougW4811-May-04 10:15
DougW4811-May-04 10:15 
GeneralRe: Query, DateTime Pin
Michael P Butler11-May-04 10:25
Michael P Butler11-May-04 10:25 
GeneralRe: Query, DateTime Pin
DougW4811-May-04 13:16
DougW4811-May-04 13:16 
GeneralRe: Query, DateTime Pin
Heath Stewart11-May-04 11:07
protectorHeath Stewart11-May-04 11:07 
GeneralRe: Query, DateTime Pin
DougW4811-May-04 15:02
DougW4811-May-04 15:02 
GeneralRe: Query, DateTime Pin
Heath Stewart11-May-04 16:21
protectorHeath Stewart11-May-04 16:21 
Trust me - using parameters is so much better. You can add them programmatically, as there is no other way! Smile | :)

For example (and I'm assuming you're using an OleDbCommand since you're using # signs):
OleDbCommand cmd = oleDbConnection.CreateCommand();
cmd.CommandText = "SELECT * FROM MyTable WHERE DateCol BETWEEN ? AND ?";
cmd.Parameters.Add("StartDate", OleDbType.DBDate).Value = DateTime.Parse("5/4/04");
cmd.Parameters.Add("EndDate", OleDbType.DBDate).Value = DateTime.Parse("5/11/04");
OleDbDataReader reader = null;
try
{
  oleDbConnection.Open();
  reader = cmd.ExecuteReader();
  // ...
}
catch (Exception e)
{
  Console.Error.WriteLine(e.Message);
}
finally
{
  if (reader != null) reader.Close();
  oleDbConnection.Close();
}
Of course, you could use this command with an OleDbDataAdapter as well - this is just an example.

Still, though it is unusual that it's treating it as a string. You're not using quotes and # signs, are you?

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: Query, DateTime Pin
DougW4811-May-04 16:47
DougW4811-May-04 16:47 
GeneralRe: Query, DateTime Pin
DougW4811-May-04 18:07
DougW4811-May-04 18:07 
Generalsetting time on Zip Entry Pin
elena1234511-May-04 8:09
elena1234511-May-04 8:09 
GeneralRe: setting time on Zip Entry Pin
Jeff Varszegi11-May-04 9:00
professionalJeff Varszegi11-May-04 9:00 
GeneralRe: setting time on Zip Entry Pin
Heath Stewart11-May-04 9:20
protectorHeath Stewart11-May-04 9:20 
GeneralRe: setting time on Zip Entry Pin
Jeff Varszegi12-May-04 6:58
professionalJeff Varszegi12-May-04 6:58 
GeneralRe: setting time on Zip Entry Pin
Heath Stewart12-May-04 7:38
protectorHeath Stewart12-May-04 7:38 
GeneralRe: setting time on Zip Entry Pin
Heath Stewart11-May-04 9:10
protectorHeath Stewart11-May-04 9:10 
GeneralRe: setting time on Zip Entry Pin
elena1234511-May-04 11:10
elena1234511-May-04 11:10 
GeneralRe: setting time on Zip Entry Pin
Heath Stewart11-May-04 11:13
protectorHeath Stewart11-May-04 11:13 
Generalpopup tip on form Pin
cchere11-May-04 8:02
cchere11-May-04 8:02 
GeneralRe: popup tip on form Pin
Heath Stewart11-May-04 8:54
protectorHeath Stewart11-May-04 8:54 
GeneralRe: popup tip on form Pin
cchere13-May-04 12:32
cchere13-May-04 12:32 
GeneralRounded numbers in C# Pin
spyforcer11-May-04 5:51
spyforcer11-May-04 5:51 
GeneralRe: Rounded numbers in C# Pin
Jeff Varszegi11-May-04 6:35
professionalJeff Varszegi11-May-04 6:35 
GeneralRe: Rounded numbers in C# Pin
spyforcer11-May-04 21:02
spyforcer11-May-04 21:02 
GeneralRe: Rounded numbers in C# Pin
Jeff Varszegi12-May-04 6:57
professionalJeff Varszegi12-May-04 6:57 

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.