newb question about strings

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Blue Man

    #1

    newb question about strings

    hello
    I am writing an error handling within different classes in asp.net. the
    error class reports the Exception E's string to the database.
    but it cuts big strings, if i just display the error it is ok , but when i
    send it to function to store it in database just a little part of error
    string appears.
    is that because of size of string?cuz when i change the error message by
    hand and put some shorter strings it works fine. i just declared normal
    strings like :

    string errormessage = null ;
    and for catching error :
    catch(Exception error)

    {

    string temp = error.ToString( );

    ErrorReport myrep = new
    ErrorReport(con nectionstring," 92",temp,DateTi me.Now);

    myrep.InserErro r(); // here in database it's just a little text like
    "System.Argumen tE" this short!

    Response.Write( temp); // here it apears correctly


    }


    thanks in advance


  • Paul E Collins

    #2
    Re: newb question about strings

    "Blue Man" <blueman_blog@n ospam.com> wrote:
    [color=blue]
    > [Strings truncated when written to database][/color]
    [color=blue]
    > ErrorReport myrep = new
    > ErrorReport(con nectionstring," 92",temp,DateTi me.Now);
    >
    > myrep.InserErro r(); // here in database it's just a little
    > text like "System.Argumen tE" this short!
    >
    > Response.Write( temp); // here it apears correctly[/color]

    It sounds as though the database field was declared to be shorter than the
    string you're writing into it. What data type and length are you using for
    it?

    P.

    --



    Comment

    • Ignacio Machin \( .NET/ C#  MVP \)

      #3
      Re: newb question about strings

      Hi Blue man,

      I would believe that it's a DB problem, it can be on the table definition,
      check the type of the column in the table, it may be a varchar( SIZE ) where
      size is not big enough,

      Pd:
      If you are using SPs check them too!!!

      Cheers,

      --
      Ignacio Machin,
      ignacio.machin AT dot.state.fl.us
      Florida Department Of Transportation

      "Blue Man" <blueman_blog@n ospam.com> wrote in message
      news:eMEl42FsDH A.572@TK2MSFTNG P11.phx.gbl...[color=blue]
      > hello
      > I am writing an error handling within different classes in asp.net. the
      > error class reports the Exception E's string to the database.
      > but it cuts big strings, if i just display the error it is ok , but when i
      > send it to function to store it in database just a little part of error
      > string appears.
      > is that because of size of string?cuz when i change the error message by
      > hand and put some shorter strings it works fine. i just declared normal
      > strings like :
      >
      > string errormessage = null ;
      > and for catching error :
      > catch(Exception error)
      >
      > {
      >
      > string temp = error.ToString( );
      >
      > ErrorReport myrep = new
      > ErrorReport(con nectionstring," 92",temp,DateTi me.Now);
      >
      > myrep.InserErro r(); // here in database it's just a little text like
      > "System.Argumen tE" this short!
      >
      > Response.Write( temp); // here it apears correctly
      >
      >
      > }
      >
      >
      > thanks in advance
      >
      >[/color]


      Comment

      • Blue Man

        #4
        Re: newb question about strings

        you were both right :)
        the problem was database type.
        thanks
        "Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us > wrote
        in message news:%23IKE9tGs DHA.2508@TK2MSF TNGP10.phx.gbl. ..[color=blue]
        > Hi Blue man,
        >
        > I would believe that it's a DB problem, it can be on the table[/color]
        definition,[color=blue]
        > check the type of the column in the table, it may be a varchar( SIZE )[/color]
        where[color=blue]
        > size is not big enough,
        >
        > Pd:
        > If you are using SPs check them too!!!
        >
        > Cheers,
        >
        > --
        > Ignacio Machin,
        > ignacio.machin AT dot.state.fl.us
        > Florida Department Of Transportation
        >
        > "Blue Man" <blueman_blog@n ospam.com> wrote in message
        > news:eMEl42FsDH A.572@TK2MSFTNG P11.phx.gbl...[color=green]
        > > hello
        > > I am writing an error handling within different classes in asp.net. the
        > > error class reports the Exception E's string to the database.
        > > but it cuts big strings, if i just display the error it is ok , but when[/color][/color]
        i[color=blue][color=green]
        > > send it to function to store it in database just a little part of error
        > > string appears.
        > > is that because of size of string?cuz when i change the error message by
        > > hand and put some shorter strings it works fine. i just declared normal
        > > strings like :
        > >
        > > string errormessage = null ;
        > > and for catching error :
        > > catch(Exception error)
        > >
        > > {
        > >
        > > string temp = error.ToString( );
        > >
        > > ErrorReport myrep = new
        > > ErrorReport(con nectionstring," 92",temp,DateTi me.Now);
        > >
        > > myrep.InserErro r(); // here in database it's just a little text like
        > > "System.Argumen tE" this short!
        > >
        > > Response.Write( temp); // here it apears correctly
        > >
        > >
        > > }
        > >
        > >
        > > thanks in advance
        > >
        > >[/color]
        >
        >[/color]


        Comment

        Working...