I have 2 radioButton "Woman and Man" and I want that these go to my data base... I create array string and stay:
string sex = "'" + "radiobutton..text" + "'"; string[] text = new string[2];text[0] = radioButton1.Text;
text[1] = radioButton2.Text;
But I when a debug my code I see a error: What the lines not is like the rows.Thank you a lot!!!! again

RadioButton
bloeser33615
In this code doesn't error. But when I compiler and it executes more I have a column in my table in my data base get it.. I can't put the value of my radiobutton inmy column... because always the value of my radiobutton1.text is stored...
vrushali
saddy
Are you having the problem with getting all the radiobutton text values in your database
You might want to check your code where you iterate through the String array to store into the database.
Thanks,
Rashmi
rbz
The code is here:
string
sex = "'" + radioButton1.Text + "'"; string[] text = new string[2];text[0] = radioButton1.Text;
text[1] = radioButton2.Text;
What is error here
Thank you.
Jocker23
Okay.. now I had more a problem I did it and my code stayed:
//cria-se um novo comando mysql
MySqlCommand com =
new MySqlCommand();
try{
com.Connection = Conexao_mysql();
StringBuilder query =
new StringBuilder();query.Append("INSERT INTO ");
query.Append(table);
query.Append(" (nick,email,nome,datanasc,ruaenumero,bairro,cidade,cep,pais,sexo,estado,home_page) VALUES (");
query.Append((nick));
query.AppendFormat(", {0}", (email));
query.AppendFormat(", {0}", (nome));
query.AppendFormat(", {0}", (datanasc));
query.AppendFormat(", {0}", (ruaenumero));
query.AppendFormat(", {0}", (bairro));
query.AppendFormat(", {0}", (cidade));
query.AppendFormat(", {0}", (cep));
query.AppendFormat(", {0}", (pais));
query.AppendFormat(", {0}", (sexo));
query.AppendFormat(", {0}", (estado));
query.AppendFormat(", {0}", (home_page));
query.Append(")");
com.CommandText = query.ToString();
And I already put other things in my code for example :
private void radioButton2_CheckedChanged(object sender, System.EventArgs e){
string sexo;sexo = ((RadioButton)sender).Text;
if (radioButton2.Checked == true){
sexo = "F";
}
else{
sexo = "M";
}
}
protected void RadioButton1_CheckedChanged(object sender, System.EventArgs e){
string sexo;sexo = ((RadioButton)sender).Text;
if (radioButton1.Checked == true){
sexo = "M";
}
else{
sexo = "F";
}
}
}
}
And now for give a fill in my data base I did It... with "M" or "F" Okay
string
sexo = radioButton1.Checked "M":"F";and here I have a method that call him :
SQL_methods.Insert_SQL(sexo);
Only that now the values will go to my data base.. only with the value standar of my data base ... Then he goes how 0 or any other thing that I put...
Thank you again!
Jangu
to insert the text value into the database on each of the items chosen/stored in the array, the pseudo would be:
for each item in string array
generate SQL Insert command including the current item in the string array (value) to give as the value
ExecuteNonQuery()
next
so...
//create your SQLCommand objects etc....
SqlCommand theSQLCommand = new SqlCommand();
foreach(string currentItem in theStringArray)
{
string theInsertStatement = this.DoGenerateSqlInsertStatement(currentItem);
theSQLCommand.CommandText = theInsertStatement;
theSQLCommand.ExecuteNonQuery();
}
..
..
private string DoGenerateSqlInsertCommand(string theValueParameter)
{
System.Text.StringBuilder theInsertStatement = new System.Text.StringBuilder();
theInsertStatement.Append("INSERT INTO yourTable (FieldName)");
theInsertStatement.Append("VALUES (");
theInsertStatement.Append(theValueParameter);
theInsertStatement.Append(")");
return theInsertStatement.ToString();
}
does this help of course change the variables as needed
sorcer1
Chester R