[C#] Switch Method
#1

Hey im back with spam with my questions

Im working just 4 fun on a t_magic tool and i have one problem with the Swtich(variable) method (or mysql?)

 

I have this code :

 

if (listBox1.SelectedIndex != -1)
{
string Index = listBox1.SelectedItem.ToString();
textBox2.Text = Index;
}

MySqlConnection con;
MySqlConnectionStringBuilder csb = new MySqlConnectionStringBuilder();
csb.Server = Server;
csb.UserID = user;
csb.Database = db;
csb.Password = pw;
con = new MySqlConnection(csb.ConnectionString);
MySqlConnection connection = new MySqlConnection(csb.ConnectionString);
connection.Open();

string _Index = listBox1.SelectedItem.ToString();

string _Sql1 = @"SELECT * FROM t_magic a_index WHERE a_name ="+"'"+ _Index+"'";
DataTable dttable = new DataTable();
MySqlCommand insertCommand = new MySqlCommand(_Sql1, connection);
int i = insertCommand.ExecuteNonQuery();
MySqlDataAdapter dtAdp = new MySqlDataAdapter(_Sql1, connection);
dtAdp.Fill(dttable);
string result = Convert.ToString(insertCommand.ExecuteScalar());

string _sql2 = @"SELECT * FROM t_magic a_damagetype WHERE a_name =" + "'" + _Index + "'"; //problem is here
DataTable dtttable = new DataTable();
MySqlCommand insertCommand2 = new MySqlCommand(_sql2, connection);
int g = insertCommand2.ExecuteNonQuery();
MySqlDataAdapter dtAdp1 = new MySqlDataAdapter(_sql2, connection);
dtAdp.Fill(dttable);
string result1 = Convert.ToString(insertCommand2.ExecuteScalar());
MessageBox.Show(result1); // and here : it sows me the Index from the Skill and not the Damagetyp!
switch (result1)
{
case "0":
DamageTyp.Text = "No Damage";
break;

case "1":
DamageTyp.Text = "Normal Damage";
break;

case "2":
DamageTyp.Text = "Damage in %";
break;

case "60": // 60 is the Index of a skill! i cheked if i fail!
DamageTyp.Text = "You Fail!";
break;

 

So my Problem is it shows me the Index from the Skill and not the Damagetyp, where is the fail ?



Messages In This Thread
[No subject] - by Nikolee - 09-25-2012, 08:16 PM
[No subject] - by Wizatek - 09-25-2012, 11:37 PM
[No subject] - by HateMe - 09-25-2012, 11:46 PM
[No subject] - by Nikolee - 09-26-2012, 12:24 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)