locked
Add date-value to Update-command RRS feed

  • Question

  • User1899914733 posted

    Hello,

    I wanna add a date-object as update-parameter for my objectdatasource.

    This is what i tried but failed:

    DateTime Boekdatum = DateTime.Parse(((Label)gvtransacties.Rows[e.RowIndex].FindControl("Boekdatum")).Text);
    
    ObjectDataSource1.UpdateParameters.Add("Boekdatum", DbType.Date, Boekdatum);

    It gives error:

    Error 2 Argument 3: cannot convert from 'System.DateTime' to 'string'

    What can i do?? THNX...

     

    Wednesday, January 26, 2011 4:18 PM

Answers

  • User653228039 posted

    oh, oops.  Wrong parameter:

    ObjectDataSource1.UpdateParameters.Add("Boekdatum", DbType.Date, Boekdatum.ToString());

    put the ToString on the Boekdatum parameter (the 3rd one).

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 26, 2011 5:15 PM

All replies

  • User653228039 posted

    Just try this:


    ObjectDataSource1.UpdateParameters.Add("Boekdatum", DbType.Date.ToString, Boekdatum);



    Add the ".ToString()" part.  I get this every now and then even with int going into int parameters.  

    Wednesday, January 26, 2011 4:22 PM
  • User1899914733 posted

    That gives me this errors:

    Error 2 Argument 2: cannot convert from 'method group' to 'System.Data.DbType' 

    Error 3 Argument 3: cannot convert from 'System.DateTime' to 'string' 

     

    I believe it has something to do with the format-style : Eval("Boekdatum", "{0:yyyy/MM/dd}" 

    Wednesday, January 26, 2011 5:04 PM
  • User653228039 posted

    oh, oops.  Wrong parameter:

    ObjectDataSource1.UpdateParameters.Add("Boekdatum", DbType.Date, Boekdatum.ToString());

    put the ToString on the Boekdatum parameter (the 3rd one).

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 26, 2011 5:15 PM
  • User1899914733 posted

    Cannot convert from method group to string 

    Wednesday, January 26, 2011 5:49 PM
  • User653228039 posted

    That doesn't make sense.  The Boekdatum variable is a DateTime, not a Group.  The reason you got that error before is I mistakenly told you to apply .ToString() to the DbType.Date parameter, which was incorrect.  Did you remove the .ToString from that 2nd parameter?

    Wednesday, January 26, 2011 5:59 PM
  • User1899914733 posted

    Sorry, i added .tostring instead of .tostring()

    It works now!! THNX 

    Wednesday, January 26, 2011 6:00 PM
  • User653228039 posted

    Sweet!

    Wednesday, January 26, 2011 6:01 PM