InvalidCastException in dataset designer generated code

Discussion in 'ASP .Net' started by John Dalberg, Mar 24, 2006.

  1. John Dalberg

    John Dalberg Guest

    The code below (generated by the dataset designer) is receiving an
    exception because the 'searchfor' column has nulls but this column in SQL
    Server allows nulls. What am I missing? Shouldn't the generated code check
    for DBNull first?





    [System.Diagnostics.DebuggerNonUserCodeAttribute()]
    public string SearchFor {
    get {
    try {
    return
    ((string)(this[this.tableXML.SearchForColumn])); }
    catch (System.InvalidCastException e) {
    throw new System.Data.StrongTypingException("The
    value for column \'SearchFor\' in table
    \'XMLElement\' is DBNull.", e); }
    }
    set {
    this[this.tableXML.SearchForColumn] = value;
    }
    }

    John Dalberg
     
    John Dalberg, Mar 24, 2006
    #1
    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. pepsi
    Replies:
    0
    Views:
    460
    pepsi
    Jun 26, 2003
  2. Leeor Geva
    Replies:
    1
    Views:
    445
    John Saunders
    Aug 22, 2003
  3. Zoury
    Replies:
    0
    Views:
    358
    Zoury
    Aug 21, 2003
  4. nakhi

    Designer generated code

    nakhi, Aug 22, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    324
    Kevin Spencer
    Aug 22, 2003
  5. JakeC
    Replies:
    1
    Views:
    2,744
    Cowboy \(Gregory A. Beamer\)
    Dec 15, 2003
Loading...

Share This Page