Search code examples
c#windows-phone-7datetimepicker

DatePicker type for export to SQL Azure


I'm trying to take the date selection from the DatePicker (selection of which is put back into the TextBox on screen) and then save this to my SQL Azure database, where the type is defined as date. However, I cant seem to find the right ending/format for the method to compile.

The exact error thrown is:

Error 1 'Microsoft.Phone.Controls.DatePicker' does not contain a definition for 'XXX' and no extension method 'XXX' accepting a first argument of type 'Microsoft.Phone.Controls.DatePicker' could be found (are you missing a using directive or an assembly reference?) C:\Users\Kristian Schuhmacher\Documents\Visual Studio 2010\Projects\AT2\App\AT2App\AT2App\Settings\DriverCreator.xaml.cs 40 89 AT2App

Here are some code snippets:

        private void addAccountBtn_Click(object sender, RoutedEventArgs e)
    {
        _ServiceClient.AddDriverAsync(fnameTxtBox.Text, snameTxtBox.Text, BirthDate.XXX, phonemobNumBox.Text);
    }

^(xxx is what I am trying to fill)

        private void BirthDate_ValueChanged(object sernder, DateTimeValueChangedEventArgs e)
    {
        var date = (DateTime)BirthDate.Value;
        MessageBox.Show(date.ToString("d"));
    }

^This is some code that goes with the DatePicker

     <toolkit:DatePicker  Name="BirthDate" ValueChanged="BirthDate_ValueChanged" Margin="2,180,-2,940" />

^This is the line from the .xaml

The DatePicker works fine and as it should, just I cannot get the "xxx" part of the code right to ship it off to the WCF service that will put it back into my SQL Azure database.

Any help on this would be great.

Thanks,


Solution

  • I would expect you to be able to use the same code as in the BirthDate_ValueChanged handler:

    _ServiceClient.AddDriverAsync(fnameTxtBox.Text, snameTxtBox.Text,
                                  (DateTime) BirthDate.Value, phonemobNumBox.Text);
    

    Does that not work? If not, what does the declaration of AddDriverAsync look like? If you hit Ctrl-Shift-Space after the second argument, what does Intellisense show?