Int to string
-
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; }
-
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; }
-
Int32 x = 10; String text = x.ToString();
As simple as that :) WM.
What about weapons of mass-construction?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
-
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; }
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
-
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; }
-
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; }
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
-
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; }
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
-
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
in the last case he doesn't give my param the value of "val"
-
in the last case he doesn't give my param the value of "val"
Who is 'he'?
-
in the last case he doesn't give my param the value of "val"
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