Click here to Skip to main content
15,902,636 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: Problem with accessing MS Access Date field with C++/CLI [modified] Pin
Dirkus Maximus23-Aug-10 16:28
Dirkus Maximus23-Aug-10 16:28 
GeneralRe: Problem with accessing MS Access Date field with C++/CLI Pin
Luc Pattyn23-Aug-10 16:56
sitebuilderLuc Pattyn23-Aug-10 16:56 
GeneralRe: Problem with accessing MS Access Date field with C++/CLI [modified] Pin
Dirkus Maximus23-Aug-10 20:09
Dirkus Maximus23-Aug-10 20:09 
AnswerRe: Problem with accessing MS Access Date field with C++/CLI Pin
Luc Pattyn24-Aug-10 0:45
sitebuilderLuc Pattyn24-Aug-10 0:45 
GeneralRe: Problem with accessing MS Access Date field with C++/CLI Pin
Dirkus Maximus24-Aug-10 15:43
Dirkus Maximus24-Aug-10 15:43 
GeneralRe: Problem with accessing MS Access Date field with C++/CLI Pin
Luc Pattyn24-Aug-10 16:31
sitebuilderLuc Pattyn24-Aug-10 16:31 
AnswerRe: Problem with accessing MS Access Date field with C++/CLI Pin
Luc Pattyn24-Aug-10 17:03
sitebuilderLuc Pattyn24-Aug-10 17:03 
GeneralRe: Problem with accessing MS Access Date field with C++/CLI Pin
Dirkus Maximus25-Aug-10 15:52
Dirkus Maximus25-Aug-10 15:52 
Great article Luc - very informative. I ended up having a DateTime representation of the Date instead of just a String.
// store date as DateTime object after splitting the string and converting to ints
DateTime^ dt = gcnew DateTime(yearField, monthField, dayField);

And when I need to insert it in the DB, I use the format you advocate:
// to insert into the DB, i use
String^ query = "INSERT INTO myTable (..., someDateField, ...)  Values(..., dt->ToString("yyyy'/'MM'/'dd"), ..."

To retrieve it back, I use what the JET documentation says, i.e. I convert it into the MM/DD/YY form first.
array <String^>^ strArr = fromDate->Split('/');
int dayField = Convert::ToInt32(strArr[0]);
int monthField = Convert::ToInt32(strArr[1]);
String^ yearField = Convert::ToString(strArr[2]);
// the year field only takes the last 2 digits
yearField = yearField->Substring(2,2);
String^ formattedDate = String::Concat(" #",Convert::ToString(monthField),"/", Convert::ToString(dayField),"/", yearField,"# ");
query = "SELECT * FROM myTable WHERE someDate = " + formattedDate +  ";

It's all a bit convoluted, but this method is working well now.
I don't know why (as described in my first post) this 'one digit' day didn't work while the '2-digit' one did - though I did forget to mention that I'm using quite an early version of MS Access (2003), so this problem may be fixed by now.

Just one other thing, from an MSDN forum I learned that


JET SQL supports different types. You can declare parameter type by using PARAMETERS clause. The OleDB provider in ADO.Net does not support named parameters.
GeneralRe: Problem with accessing MS Access Date field with C++/CLI [modified] Pin
Luc Pattyn25-Aug-10 16:25
sitebuilderLuc Pattyn25-Aug-10 16:25 
GeneralRe: Problem with accessing MS Access Date field with C++/CLI [modified] Pin
Dirkus Maximus26-Aug-10 14:16
Dirkus Maximus26-Aug-10 14:16 
QuestionUse of managed variables in non-ref class Pin
KlaasVersteeg20-Aug-10 2:27
KlaasVersteeg20-Aug-10 2:27 
AnswerRe: Use of managed variables in non-ref class Pin
Nish Nishant20-Aug-10 6:29
sitebuilderNish Nishant20-Aug-10 6:29 
AnswerRe: Use of managed variables in non-ref class Pin
slawomir_orlowski29-Aug-10 21:15
slawomir_orlowski29-Aug-10 21:15 
GeneralRe: Use of managed variables in non-ref class Pin
KlaasVersteeg29-Aug-10 21:21
KlaasVersteeg29-Aug-10 21:21 
QuestionHelp with Angle Rotations pls.. Pin
lgmanuel19-Aug-10 20:42
lgmanuel19-Aug-10 20:42 
AnswerRe: Help with Angle Rotations pls.. Pin
Luc Pattyn20-Aug-10 2:00
sitebuilderLuc Pattyn20-Aug-10 2:00 
QuestionHow to create a .resx file in windows forms application (VS2005) Pin
roshihans10-Aug-10 10:17
roshihans10-Aug-10 10:17 
QuestionGenerating Runtime code(structs,classes) in C++/CLI Pin
glitteringsound6-Aug-10 5:03
glitteringsound6-Aug-10 5:03 
AnswerRe: Generating Runtime code(structs,classes) in C++/CLI Pin
N a v a n e e t h6-Aug-10 8:03
N a v a n e e t h6-Aug-10 8:03 
Questionnew line on Edit Control... Pin
lgmanuel1-Aug-10 14:35
lgmanuel1-Aug-10 14:35 
AnswerRe: new line on Edit Control... Pin
Richard MacCutchan1-Aug-10 21:37
mveRichard MacCutchan1-Aug-10 21:37 
AnswerRe: new line on Edit Control... Pin
Luc Pattyn2-Aug-10 1:12
sitebuilderLuc Pattyn2-Aug-10 1:12 
QuestionHelp need on Ip Helper functions example:GetUnicastIpAddressEntry. Pin
G Haranadh31-Jul-10 18:59
G Haranadh31-Jul-10 18:59 
QuestionMap file generation on VS2008 Pin
Member 225379327-Jul-10 19:25
Member 225379327-Jul-10 19:25 
AnswerRe: Map file generation on VS2008 Pin
N a v a n e e t h27-Jul-10 19:49
N a v a n e e t h27-Jul-10 19:49 

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.