LCKB
Loading Selected [C#] - Printable Version

+- LCKB (https://lckb.dev/forum)
+-- Forum: ** OLD LCKB DATABASE ** (https://lckb.dev/forum/forumdisplay.php?fid=109)
+--- Forum: Programmers Gateway (https://lckb.dev/forum/forumdisplay.php?fid=196)
+---- Forum: Coders Talk (https://lckb.dev/forum/forumdisplay.php?fid=192)
+---- Thread: Loading Selected [C#] (/showthread.php?tid=1131)



- roseon - 09-18-2012

Hi guys ok here the thing im trying to read the selected name in the listbox and displaying it into the textbox like example selecting caracter name and showing the info of that caracter into the textbox using mysql commands strings if anyone have a clue how i can do that please help me out on this issue.




- roseon - 09-18-2012



private void listBox2_SelectedIndexChanged(object sender, EventArgs e)
{
MySqlConnection cn = new MySqlConnection("host= " + BOX1.Text + "; username= " + BOX2.Text + "; password= " + BOX3.Text + ";database= " + BOX5.Text);
Encryption = true;
BOX4.Text = database;
BOX5.Text = database1;
BOX1.Text = host;
BOX3.Text = password;
BOX2.Text = user;
textBox12.Text = " " + listBox2.Items.Count.ToString();
DataRowView PeopleRow = listBox2.SelectedItem as DataRowView;
if (PeopleRow != null && PeopleRow.Row != null && PeopleRow.Row.ItemArray != null)
{
DataRow row = PeopleRow.Row;
if (row.ItemArray.Count() > 0)

{
textBox41.Text = Convert.ToString(row["NAME"]).ToString();

try
{
this.textBox41.Text = this.listBox2.SelectedItem.ToString();
DataSet DS = new DataSet();
this.textBox41.Text = DS.Tables[0].Rows[0]["a_nick"].ToString();
this.textBox40.Text = DS.Tables[0].Rows[0]["a_level"].ToString();
this.textBox39.Text = DS.Tables[0].Rows[0]["a_job"].ToString();
this.textBox38.Text = DS.Tables[0].Rows[0]["a_skill_point"].ToString();
this.textBox37.Text = DS.Tables[0].Rows[0]["a_statpt_remain"].ToString();
this.textBox36.Text = DS.Tables[0].Rows[0]["a_str"].ToString();
this.textBox47.Text = DS.Tables[0].Rows[0]["a_dex"].ToString();
this.textBox46.Text = DS.Tables[0].Rows[0]["a_int"].ToString();
this.textBox45.Text = DS.Tables[0].Rows[0]["a_con"].ToString();
this.textBox44.Text = DS.Tables[0].Rows[0]["a_admin"].ToString();
this.textBox43.Text = DS.Tables[0].Rows[0]["a_enable"].ToString();
}
catch (Exception ex)
{
MessageBox.Show("Please select Caracter from the list!");
}
}
}




- Nikolee - 09-25-2012


Here i have an example for you, thats from my Cash Tool to see the Statpoints from the Character in a textbox

 

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

string _Sql1 = @"SELECT * FROM t_characters a_index WHERE a_nick='"+textBox16.Text+"'";
DataTable dttable = new DataTable();
MySqlCommand insertBann = new MySqlCommand(_Sql1, connection);
int i = insertBann.ExecuteNonQuery();
MySqlDataAdapter dtAdp = new MySqlDataAdapter(_Sql1, connection);
dtAdp.Fill(dttable);
string result = Convert.ToString(insertBann.ExecuteScalar());

DataTable datatable = new DataTable();
String sql1 = @"SELECT * FROM `t_characters` `a_statpt_dex` WHERE a_index =" + result + ";";
MySqlDataAdapter dataAdapter = new MySqlDataAdapter(sql1, connection);
dataAdapter.Fill(datatable);
textBox15.DataBindings.Add("Text", datatable, "a_statpt_dex"); // that is what are you searching for




- roseon - 09-25-2012

thank u