I have connected my program to an access database file, and when I select the numbers in the combobox (1, 2, 3 etc.) I want to automatically fill the other textboxes in the form .. it works if it's a string .. for example if i select a string (e.g. name) in the combobox it automatically fills the other textboxes, but it doesn't work if it's an integer.
I know I must convert to int, but I don't know how because i have a query:
Expand|Select|Wrap|Line Numbers
- private void iD_FurnizorComboBox_SelectedIndexChanged_1(object sender, EventArgs e)
- {
- try
- {
- connection.Open();
- OleDbCommand command = new OleDbCommand();
- command.Connection = connection;
- string query;
- query = "select * from Furnizori where id_furnizor = '" + iD_FurnizorComboBox.Text + "'";
- int query_test = int.Parse(query);
- command.CommandText = query;
- OleDbDataReader reader = command.ExecuteReader();
- while (reader.Read())
- {
- numeTextBox.Text = reader["nume"].ToString();
- adresaTextBox.Text = reader["adresa"].ToString();
- localitateTextBox.Text = reader["localitate"].ToString();
- judetTextBox.Text = reader["judet"].ToString();
- }
- connection.Close();
- }
- catch (Exception ex)
- {
- throw ex;
- }
- finally
- {
- connection.Close();
- }
- }