Re: I got an error

Discussion in 'ASP .Net' started by Mr. Arnold, Jul 2, 2010.

  1. Mr. Arnold

    Mr. Arnold Guest

    redbull wrote:
    > Hi guys, I've created a simple webpage with a datagridview, my business
    > object.
    > If i try to modify a record i get an error on date value:
    >
    > Dettagli eccezione: System.InvalidOperationException: Impossible to
    > convert the value of parameter 'DataNascita' from 'System.String' to
    > 'System.DateTime'.
    > What should I do?
    > Thanks


    You can't populate a DateTime value field or variable with string data
    representing a date and time.

    The string date and time must be converted over to System.Datetime
    before the field or variable can be populated by string data the
    represents a date and time.

    You should look up how to use the 'Convert' statement.
     
    Mr. Arnold, Jul 2, 2010
    #1
    1. Advertising

  2. Mr. Arnold

    Mr. Arnold Guest

    redbull wrote:
    >
    > "Mr. Arnold" <> ha scritto nel messaggio
    > news:...
    >> redbull wrote:
    >>> Hi guys, I've created a simple webpage with a datagridview, my
    >>> business object.
    >>> If i try to modify a record i get an error on date value:
    >>>
    >>> Dettagli eccezione: System.InvalidOperationException: Impossible to
    >>> convert the value of parameter 'DataNascita' from 'System.String' to
    >>> 'System.DateTime'.
    >>> What should I do?
    >>> Thanks

    >>
    >> You can't populate a DateTime value field or variable with string data
    >> representing a date and time.
    >>
    >> The string date and time must be converted over to System.Datetime
    >> before the field or variable can be populated by string data the
    >> represents a date and time.
    >>
    >> You should look up how to use the 'Convert' statement.

    >
    >
    > to insert the value i do:
    > persona.data= Convert.ToDateTime(Me.TextBox3.Text)
    >
    > The problem raises when i click on update dategridview.....but how can I
    > modify code related to selcet/update/insert in datagridview?
    > Thanks
    >
    >


    What is 'DataNascita', because that's what it doesn't like?
     
    Mr. Arnold, Jul 2, 2010
    #2
    1. Advertising

  3. Mr. Arnold

    Mr. Arnold Guest

    redbull wrote:
    >
    >
    >
    > "Mr. Arnold" <> ha scritto nel messaggio
    > news:#...
    >
    >> What is 'DataNascita', because that's what it doesn't like?

    >
    > db sqlserver 2008, datanascita means "birth date" and it is a date type
    > on the db
    > on the business object I have defined the property DataNascita like a
    > datetime
    >
    > The problem is got when i call update function on datagridview....
    >
    >


    Well, you're going to need to come up with something else, because
    apparently that variable type cannot be cast to a string by the
    gridview, unless you step in with a function that does so.
     
    Mr. Arnold, Jul 5, 2010
    #3
  4. Mr. Arnold

    Mr. Arnold Guest

    redbull wrote:
    >
    >
    > "Mr. Arnold" <> ha scritto nel messaggio
    > news:eXymfC$...
    >
    >> Well, you're going to need to come up with something else, because
    >> apparently that variable type cannot be cast to a string by the
    >> gridview, unless you step in with a function that does so.

    >
    > How can I do it? Give m some help please.
    > I don't know what I must do


    The control has events like update/select/delete etc, etc on the
    client-side and the server-side. On the client-side, you can call a
    Javascript function that can look at the field and do the conversion to
    the type you need. On the server-side, you can goto the event for the
    control's method on the codebehind file and do something there.

    You should use Bing or Google to look up the events on both sides for
    the control and find examples on how you can use the events with code.
     
    Mr. Arnold, Jul 5, 2010
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ^CrazyCoder^
    Replies:
    3
    Views:
    7,329
    Terrence Benade
    Sep 15, 2003
  2. Hai Nguyen

    I got this Error

    Hai Nguyen, Jan 12, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    629
    Hai Nguyen
    Jan 12, 2004
  3. Ian
    Replies:
    2
    Views:
    326
    Rick Spiewak
    May 8, 2004
  4. Replies:
    1
    Views:
    3,502
    CyberOwl
    Sep 7, 2009
  5. Deepak
    Replies:
    2
    Views:
    1,721
    Rolf Magnus
    Nov 24, 2004
Loading...

Share This Page