Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. send string to sql problem

send string to sql problem

Scheduled Pinned Locked Moved ASP.NET
helpcsharpasp-netdatabasetutorial
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    hakanaktan
    wrote on last edited by
    #1

    Hi, i have a few textbox in my asp.net form. I have to add strings and save it as 1 string to the nvarchar typed column of my sql table. Here is the result of string: "1,-,3,4,-,-,-,-," When i try to insert this string to my column it gives this error: System.Data.SqlClient.SqlException: String or binary data would be truncated. The statement has been terminated. at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at serviceReport.newReport.Insert_Click(Object sender, EventArgs e) in C:\Inetpub\wwwroot\serviceReport\newReport.aspx.vb:line 245 Does someone knows how to send this string? In string if textBox is free i use "-" , if you know another way i can use it too.. thanx in advance.. --junior coder--

    V 1 Reply Last reply
    0
    • H hakanaktan

      Hi, i have a few textbox in my asp.net form. I have to add strings and save it as 1 string to the nvarchar typed column of my sql table. Here is the result of string: "1,-,3,4,-,-,-,-," When i try to insert this string to my column it gives this error: System.Data.SqlClient.SqlException: String or binary data would be truncated. The statement has been terminated. at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery() at serviceReport.newReport.Insert_Click(Object sender, EventArgs e) in C:\Inetpub\wwwroot\serviceReport\newReport.aspx.vb:line 245 Does someone knows how to send this string? In string if textBox is free i use "-" , if you know another way i can use it too.. thanx in advance.. --junior coder--

      V Offline
      V Offline
      Vasudevan Deepak Kumar
      wrote on last edited by
      #2

      The error message normally indicates that the column where you are intending to save this value is of size which is less than the length of the string that you are passing. Deepak Kumar Vasudevan Personal Web: http://vdeepakkumar.netfirms.com/ I Blog At: http://deepak.blogdrive.com/

      H 1 Reply Last reply
      0
      • V Vasudevan Deepak Kumar

        The error message normally indicates that the column where you are intending to save this value is of size which is less than the length of the string that you are passing. Deepak Kumar Vasudevan Personal Web: http://vdeepakkumar.netfirms.com/ I Blog At: http://deepak.blogdrive.com/

        H Offline
        H Offline
        hakanaktan
        wrote on last edited by
        #3

        no it is impossible cause i send a string like: "1,-,3,-,4,5,6,7,8,9,10" it's length can be 25 maximum and in sql column type is nvarchar and mazlength is 4000. there ' s something wrong with my string? --junior coder--

        V 1 Reply Last reply
        0
        • H hakanaktan

          no it is impossible cause i send a string like: "1,-,3,-,4,5,6,7,8,9,10" it's length can be 25 maximum and in sql column type is nvarchar and mazlength is 4000. there ' s something wrong with my string? --junior coder--

          V Offline
          V Offline
          Vasudevan Deepak Kumar
          wrote on last edited by
          #4

          Hi: Can you check out the String that is being sent as CommandText to to the ExecuteNonQuery? You can check that out in a Watch. I think a column is being mismatched. Deepak Kumar Vasudevan Personal Web: http://vdeepakkumar.netfirms.com/ I Blog At: http://deepak.blogdrive.com/

          H 1 Reply Last reply
          0
          • V Vasudevan Deepak Kumar

            Hi: Can you check out the String that is being sent as CommandText to to the ExecuteNonQuery? You can check that out in a Watch. I think a column is being mismatched. Deepak Kumar Vasudevan Personal Web: http://vdeepakkumar.netfirms.com/ I Blog At: http://deepak.blogdrive.com/

            H Offline
            H Offline
            hakanaktan
            wrote on last edited by
            #5

            no problem with command.because it works if i do not use the "-" for the empty textBoxes. But i need all textBox.Text values like an array. Is there another way? i wrote the total string in a textBox and here it is: -,2,-,4,5,-,7,-,9,-, So if this problem is hard to solve ,i may change my way to collect the text value of my textBoxes . Do you know another way to collect the text in one string to convert an array in future codes.i can not insert this string to nvarchar(4000) typed column heeeelp:(( --junior coder--

            H 1 Reply Last reply
            0
            • H hakanaktan

              no problem with command.because it works if i do not use the "-" for the empty textBoxes. But i need all textBox.Text values like an array. Is there another way? i wrote the total string in a textBox and here it is: -,2,-,4,5,-,7,-,9,-, So if this problem is hard to solve ,i may change my way to collect the text value of my textBoxes . Do you know another way to collect the text in one string to convert an array in future codes.i can not insert this string to nvarchar(4000) typed column heeeelp:(( --junior coder--

              H Offline
              H Offline
              hakanaktan
              wrote on last edited by
              #6

              i solved my problem:-D i am really silly! i had changed the type of a column int to nvarchar vut it's length was 10 thanx for your help have i said i am silly:) --junior coder--

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups