none
Object cannot be cast from DBNull to other types.

    Question

  •  lstr_pmt.id = ids_tnetprompts.Rows[0]["Prompt"].ToString();
                    lstr_pmt.name = ids_tnetprompts.Rows[0]["Name"].ToString();
                    lstr_pmt.dtype = Convert.ToInt32(ids_tnetprompts.Rows[0]["type"]);
                    lstr_pmt.max_len = Convert.ToInt32(ids_tnetprompts.Rows[0]["Max_Len"]);
      lstr_pmt.sclar = Convert.ToInt32(ids_tnetprompts.Rows[0]["scaler"]);
                    lstr_pmt.valied_resp = ids_tnetprompts.Rows[0]["valid_resp"].ToString();
                    lstr_pmt.valied_file = ids_tnetprompts.Rows[0]["valid_file"].ToString();
                    lstr_pmt.valied_attr = Convert.ToInt32(ids_tnetprompts.Rows[0]["valid_attr"]);

    i'm getting the error that line how can i solve that problem plese help me??

                 
    Monday, May 14, 2012 9:53 AM

Answers

  • Hi Sateesh,

    Thanks for your post!

    This forum is for data access to SQL Server using SQL Native Client, OLEDB, ODBC, ADO, WDAC/MDAC, JDBC, or SOAP/HTTP. If you have any problem about C# language, please post it to related forum.

    Here is a link for C#: http://social.msdn.microsoft.com/Forums/en/csharpgeneral/threads


    Best Regards,
    Iric
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, May 15, 2012 3:01 AM
  • It means that ids_tnetprompts.Rows[0]["scaler"] is null. Check for nulls before you convert any value. You probably would have to do for all the columns or just deal with the columns that are nullable.

    -ravi

    Tuesday, May 15, 2012 1:48 PM
  • dear ravi ,

        i check for nulls yes  it is null value .now how can i solve this error???


    sateesh siriki

    Wednesday, May 16, 2012 11:31 AM

All replies

  • Hi Sateesh,

    Thanks for your post!

    This forum is for data access to SQL Server using SQL Native Client, OLEDB, ODBC, ADO, WDAC/MDAC, JDBC, or SOAP/HTTP. If you have any problem about C# language, please post it to related forum.

    Here is a link for C#: http://social.msdn.microsoft.com/Forums/en/csharpgeneral/threads


    Best Regards,
    Iric
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, May 15, 2012 3:01 AM
  • It means that ids_tnetprompts.Rows[0]["scaler"] is null. Check for nulls before you convert any value. You probably would have to do for all the columns or just deal with the columns that are nullable.

    -ravi

    Tuesday, May 15, 2012 1:48 PM
  • dear ravi ,

        i check for nulls yes  it is null value .now how can i solve this error???


    sateesh siriki

    Wednesday, May 16, 2012 11:31 AM