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. General Programming
  3. C#
  4. Int to string

Int to string

Scheduled Pinned Locked Moved C#
helpcsharpregexquestion
10 Posts 5 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.
  • R Offline
    R Offline
    Rmokkenstorm
    wrote on last edited by
    #1

    i use this code.. but it's not working. i use visual C# 2005. in my selection string there are 3 parameters (:PARAM3) this is just one sampje the error is : The best overloaded method match for 'string.this[int]' has some invalid arguments so i have to put it to string somewhere.. but i don't know how and where can anyone help me? if (textBox2.Text == string.Empty) { dBANBM_T075_BORGTOCHTTableAdapter.Connection.ConnectionString[":PARAM3"] = "%"; } else { dBANBM_T075_BORGTOCHTTableAdapter.Connection.ConnectionString[":PARAM3"].Value = textBox2.Text; }

    W J G J 4 Replies Last reply
    0
    • R Rmokkenstorm

      i use this code.. but it's not working. i use visual C# 2005. in my selection string there are 3 parameters (:PARAM3) this is just one sampje the error is : The best overloaded method match for 'string.this[int]' has some invalid arguments so i have to put it to string somewhere.. but i don't know how and where can anyone help me? if (textBox2.Text == string.Empty) { dBANBM_T075_BORGTOCHTTableAdapter.Connection.ConnectionString[":PARAM3"] = "%"; } else { dBANBM_T075_BORGTOCHTTableAdapter.Connection.ConnectionString[":PARAM3"].Value = textBox2.Text; }

      W Offline
      W Offline
      WillemM
      wrote on last edited by
      #2

      Int32 x = 10; String text = x.ToString(); As simple as that :) WM.
      What about weapons of mass-construction?

      R 1 Reply Last reply
      0
      • W WillemM

        Int32 x = 10; String text = x.ToString(); As simple as that :) WM.
        What about weapons of mass-construction?

        R Offline
        R Offline
        Rmokkenstorm
        wrote on last edited by
        #3

        but where should i put this.. my value of my param2 is given while running the application. this actually i did know. but how to implent it in my application is the question:D

        1 Reply Last reply
        0
        • R Rmokkenstorm

          i use this code.. but it's not working. i use visual C# 2005. in my selection string there are 3 parameters (:PARAM3) this is just one sampje the error is : The best overloaded method match for 'string.this[int]' has some invalid arguments so i have to put it to string somewhere.. but i don't know how and where can anyone help me? if (textBox2.Text == string.Empty) { dBANBM_T075_BORGTOCHTTableAdapter.Connection.ConnectionString[":PARAM3"] = "%"; } else { dBANBM_T075_BORGTOCHTTableAdapter.Connection.ConnectionString[":PARAM3"].Value = textBox2.Text; }

          J Offline
          J Offline
          J4amieC
          wrote on last edited by
          #4

          COnnection.ConnectionString returns a string according to the documentation[^]. So trying to use a string-indexer will fail. The error message says: The best overloaded method match for 'string.this[int]' has some invalid arguments which is to say you can use a numeric-indexer on a string variable, to retrieve the character at that index. string myString = "HelloWorld" char firstChar = myString[0]; firstChar would contain the letter 'H' You should tell us what you are trying to achieve, rather than how you are trying to achieve it - that way maybe someone can give you more help. Current blacklist svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour

          1 Reply Last reply
          0
          • R Rmokkenstorm

            i use this code.. but it's not working. i use visual C# 2005. in my selection string there are 3 parameters (:PARAM3) this is just one sampje the error is : The best overloaded method match for 'string.this[int]' has some invalid arguments so i have to put it to string somewhere.. but i don't know how and where can anyone help me? if (textBox2.Text == string.Empty) { dBANBM_T075_BORGTOCHTTableAdapter.Connection.ConnectionString[":PARAM3"] = "%"; } else { dBANBM_T075_BORGTOCHTTableAdapter.Connection.ConnectionString[":PARAM3"].Value = textBox2.Text; }

            G Offline
            G Offline
            Guffa
            wrote on last edited by
            #5

            On what line do you get the error? You are using the Value property on only one of them. Shouldn't be on both? --- b { font-weight: normal; }

            R 1 Reply Last reply
            0
            • G Guffa

              On what line do you get the error? You are using the Value property on only one of them. Shouldn't be on both? --- b { font-weight: normal; }

              R Offline
              R Offline
              Rmokkenstorm
              wrote on last edited by
              #6

              both line's give the error what i'm trying to achieve is the following i've got one datagrid, 3 textboxes and a button in the textboxes you can fill in a value wich should be param2, param3, param4. on this values he will search my database. select * From Table where (Column like :PARAM2). if there's no value he fills in a wildcard. if i don't do that he's got a empty parameter so he won't be able to select something. the button fill's the database with the parameters. en show's the data in the datagrid. that's the idee. i'de had it working on visual studio 2003.net also with c# and using a Oracle database now visual C# 2005 and a acces database. so once the code did work. hopefully this make some sense

              1 Reply Last reply
              0
              • R Rmokkenstorm

                i use this code.. but it's not working. i use visual C# 2005. in my selection string there are 3 parameters (:PARAM3) this is just one sampje the error is : The best overloaded method match for 'string.this[int]' has some invalid arguments so i have to put it to string somewhere.. but i don't know how and where can anyone help me? if (textBox2.Text == string.Empty) { dBANBM_T075_BORGTOCHTTableAdapter.Connection.ConnectionString[":PARAM3"] = "%"; } else { dBANBM_T075_BORGTOCHTTableAdapter.Connection.ConnectionString[":PARAM3"].Value = textBox2.Text; }

                J Offline
                J Offline
                Josh Smith
                wrote on last edited by
                #7

                The ConnectionString property returns a string. You cannot index into a string with a string value...

                // Bad
                dBANBM_T075_BORGTOCHTTableAdapter.Connection.ConnectionString[":PARAM3"] = "%";

                As the compiler error told you, you have to index into the string with an integer (a whole number).

                // Better
                dBANBM_T075_BORGTOCHTTableAdapter.Connection.ConnectionString[4] = '%';

                Most likely what you are trying to achieve is something like this:

                // Best
                string val;
                if( textBox2.Text != string.Empty )
                val = textBox2.Text;
                else
                val = "%";

                dBANBM_T075_BORGTOCHTTableAdapter.Connection.ConnectionString = dBANBM_T075_BORGTOCHTTableAdapter.Connection.ConnectionString.Replace( ":PARAM3", val );

                Josh

                R 1 Reply Last reply
                0
                • J Josh Smith

                  The ConnectionString property returns a string. You cannot index into a string with a string value...

                  // Bad
                  dBANBM_T075_BORGTOCHTTableAdapter.Connection.ConnectionString[":PARAM3"] = "%";

                  As the compiler error told you, you have to index into the string with an integer (a whole number).

                  // Better
                  dBANBM_T075_BORGTOCHTTableAdapter.Connection.ConnectionString[4] = '%';

                  Most likely what you are trying to achieve is something like this:

                  // Best
                  string val;
                  if( textBox2.Text != string.Empty )
                  val = textBox2.Text;
                  else
                  val = "%";

                  dBANBM_T075_BORGTOCHTTableAdapter.Connection.ConnectionString = dBANBM_T075_BORGTOCHTTableAdapter.Connection.ConnectionString.Replace( ":PARAM3", val );

                  Josh

                  R Offline
                  R Offline
                  Rmokkenstorm
                  wrote on last edited by
                  #8

                  in the last case he doesn't give my param the value of "val"

                  J R 2 Replies Last reply
                  0
                  • R Rmokkenstorm

                    in the last case he doesn't give my param the value of "val"

                    J Offline
                    J Offline
                    Josh Smith
                    wrote on last edited by
                    #9

                    Who is 'he'?

                    1 Reply Last reply
                    0
                    • R Rmokkenstorm

                      in the last case he doesn't give my param the value of "val"

                      R Offline
                      R Offline
                      Rmokkenstorm
                      wrote on last edited by
                      #10

                      he is my program this is the code i use now the "val" get's his value form the program. that is the % if the field is empty. or else the value that is typed in the textfield. but the parameter doesn't get this value

                      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