Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
OleDB syntax with a Selected date Field
Message
From
20/11/2012 10:58:17
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01557578
Message ID:
01557656
Views:
59
Gerard

You can pass a datetime type to VFP as a parameter when you need a VFP date type.
test.Parameters["DateTime"] = dt

should work if dt is of type datetime.





>Hi Bill. Thanks for that.
>
>How do you initialise the date parameter to a string as VFP will expect a VFP date
>I get an error with --> test.Parameters["DateTime"] = dt.ToString("yyyyMMdd");
>Regards,
>Gerard
>
>
>>>Hi Borislav. Thanks for replying.
>>>When I insert the code I get a compile error:
>>>...cannot implcitly convert type 'string' to stsrem.Data.Oledb.OledbParameter for the dt.Tostring() line
>>>
>>>Also, what do I put in my Select String ? Select * from MyTable where MyDateField = @DateTime ??
>>>
>>>Tia
>>>Gerard
>>>
>>>
>>>>>Hi.
>>>>>Uiing C# to read in a VFP Table
>>>>>Trying to get a Select command form VFP with a date Field and using a parameter
>>>>>My Select Command that I want is like: Select * from MyTable where DateField >= MydateControl.Date
>>>>>
>>>>>I am using Oledb
>>>>>MydateControl is a c# Date Control and hlds current date
>>>>>I want to use a Parameter
>>>>>
>>>>>I end up getting a few different messages like Syntax error etc
>>>>>Anybody know the correct syntax for both the Select and adding the Parameter
>>>>>
>>>>>Tia
>>>>>Gerard
>>>>
>>>>
>>>>DateTime dt = DateTime.Now;
>>>>OleDbCommand test = new OleDbCommand();
>>>>test.Parameters.Add("@DateTime", OleDbType.DBDate);
>>>>test.Parameters["DateTime"] = dt.ToString("yyyyMMdd");
>>>>
>>>>?
>>
>> VFP Syntax uses ? instead of @parm
>>Select * from MyTable where MyDateField = ?
Anyone who does not go overboard- deserves to.
Malcolm Forbes, Sr.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform