Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
OleDB syntax with a Selected date Field
Message
 
To
22/11/2012 11:29:51
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01557578
Message ID:
01557820
Views:
32
Hi Bill
I would have used the adjectives Cute Friendly, Charming,Athletic about Kerry people (Tralee is in County Kerry) as opposed to persistent and definitisly not Stubborn !!
You obviously have a an excellent pedigree as you share a surname with some very famous Irish people.. Past Taoiseach Garret Fitzgerald (Prime Minister) and Way Past (Desmond Fitzgerald..Feudal Lord c 15th century) !!


Regards,
Gerard

>Gerard
>Glad to help.
>All 4 of my grandparents were from Tralee and they always told me that Tralee people are persistent (aka - stubborn)!
>
>
>
>
>
>>Hi BIll.
>>Got this working, finally
>>
>>What did NOT work:
>>oCommX.Parameters.Add(new OleDbParameter("@MyDate", dtX));
>>
>>What did work:
>> oDaX.SelectCommand.Parameters.Add("@MyDate", OleDbType.Date).Value = dtX;
>>
>>I was just adding the Parameter to the Command , whereas your sample adds the Parameter to the SelectCommand Property of the DataAdapter..... I would never have figured that out in a month of Sundays , particulalrly as adding the Parameter to the Command object was not giving an error.
>>
>>
>>Many thabks again and I really appreciate your persistence.
>>
>>Regards,
>>Gerard
>>
>>
>>
>>
>>>Gerard
>>>
>>>This works here:
>>>
>>>
>>>
>>> OleDbCommand oCommX = new OleDbCommand();
>>>      //string oConnX = @"Provider=VFPOLEDB.1; Data Source=" + @"C:\DISA\DIS2012";
>>>      string oConnX = @"Provider=VFPOLEDB.1; Data Source=" + @"C:\apps\safesoun\pro6\acdata";
>>>      string oSelX = "Select * from stores01 WHERE adddate <= ? ";
>>>      DateTime dtX = DateTime.Now;
>>>      OleDbDataAdapter oDaX = new OleDbDataAdapter(oSelX, oConnX);
>>>      oDaX.SelectCommand.Parameters.Add("@MyDate", OleDbType.Date).Value = dtX;
>>>      DataSet oDsX = new DataSet();
>>>      oDaX.Fill(oDsX);
>>></pre?
>>>
>>>
>>>
>>>>Hi BIll
>>>>Tried that 
>>>>
>>>>oCommX.Parameters.Add(new OleDbParameter("@MyDate", dtX));
>>>>
>>>>Same result I'm afraid (no value given for one or more required parameters)
>>>>regards,
>>>>Gerard
>>>>
>>>>
>>>>
>>>>>Gerard
>>>>>Try changing this:
>>>>>oCommX.Parameters.Add(new OleDbParameter("?MyDate ", dtX));
>>>>>
>>>>>to 
>>>>>
>>>>>this:
>>>>>oCommX.Parameters.Add(new OleDbParameter("@MyDate ", dtX));
>>>>>
>>>>>Confusing, but when you add it you use "@" and when you use it, you use "?"
>>>>>
>>>>>
>>>>>
>>>>>><pre>
>>>>>>Hi Bill. My code is below:
>>>>>>
>>>>>> OleDbCommand oCommX = new OleDbCommand();
>>>>>> string oConnX = @"Provider=VFPOLEDB.1; Data Source=" + @"C:\DISA\DIS2012";
>>>>>> string oSelX = "Select AAP_TITLE from DFAAP WHERE AAP_DATEBR >= ? ";
>>>>>> DateTime dtX = DateTime.Now;
>>>>>> oCommX.Parameters.Add(new OleDbParameter("?MyDate ", dtX));
>>>>>>OleDbDataAdapter oDaX = new OleDbDataAdapter(oSelX, oConnX);
>>>>>>DataSet oDsX = new DataSet();
>>>>>>oDaX.Fill(oDsX);
>>>>>>
>>>>>>If I Change the where clause to 1=1, rows are selected fine
>>>>>>The AAP_DATEBR is a Date Field in a DBF thats part of a .DBC
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>>>
>>>>>>>>Hi Borislav
>>>>>>>>=======================================================
>>>>>>>>string oSel = "Select Myfield1,MyDate from MYTable WHERE MyDate <= ? ";
>>>>>>>>DateTime dt = DateTime.Now;
>>>>>>>>oComm.Parameters.Add(new OleDbParameter("?MyDate ", dt));
>>>>>>>>=======================================================
>>>>>>>>
>>>>>>>>Still get a message: No value given for one or more required parameters
>>>>>>>>Beginnig to think that maybe you cannot use parameters with OleDb and Foxpro and a Date Field and maybe I have to change 
>>>>>>>> to stringing in everything (and I know..leave it open to Sql Injection etc )
>>>>>>>>What do you think ?
>>>>>>>>Have you yourself ever got OLEDB with a Date Parameter to work ?
>>>>>>>>
>>>>>>>>Regards,
>>>>>>>>Gerard
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>>>Hi Borislav.
>>>>>>>>>>Yes I have seen Ricks link but nowhere do I see an example with a DATE in the parameter
>>>>>>>>>>Regards,
>>>>>>>>>>Gerard
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>string oSel = "Select Myfield1,MyDate from MYTable WHERE MyDate <= ? ";
>>>>>>>>>DateTime dt = DateTime.Now;
>>>>>>>>>oComm.Parameters.Add(new OleDbParameter("?MyDate ", dt));
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>?
>>>>>>>
>>>>>>>Gerard
>>>>>>>
>>>>>>>It might help to show all your code, including the code executing the command
Previous
Reply
Map
View

Click here to load this message in the networking platform