how do i retrieve the data from database when code is selected? E.g: on my database, i got Code column and Description column.. and for the Code column, i got "0001" and for the Description column, i got "Abc", or it could be said that the description for "0001" is "Abc".
I already tried many times, but it keep failed, anyone know how? I want to do when the user's select "0001", the "Abc" come out in the Description column
Here is the code:
string connectionString = (@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=\Archives\Projects\Program\Sell System\Sell System\App_Data\db1.accdb;Persist Security Info=False;");
int y = 16;
UpdateTextPosition();
OleDbDataReader dReader;
OleDbConnection conn = new OleDbConnection(connectionString);
conn.Open();
OleDbCommand cmd = new OleDbCommand("SELECT [Code] FROM [Data] WHERE Code='@Code'", conn);
cmd.Parameters.Add(new OleDbParameter("@Code", OleDbType.VarChar, 200, "Code"));
cmd.Parameters["@Code"].Value = textBoxCodeContainer[0][y].Text;
dReader = cmd.ExecuteReader();
AutoCompleteStringCollection codesCollection = new AutoCompleteStringCollection();
while (dReader.Read())
{
string numString = dReader[0].ToString().PadLeft(4, '0');
codesCollection.Add(numString);
}
dReader.Close();
conn.Close();
Here is link of images: https://www.dropbox.com/s/5q8pyztqy7ejupy/Capture.PNG (This image is database that connected to program)
https://www.dropbox.com/s/mlwkvuvtxww2hjm/Untitled_2.png (This image show the code column is working well, but when the code is selected, the description not come out in description column)
Here is my problem: I want when the code is selected as displayed in Untitled_2.png, the description for "0001" (shown in Untitled_2.png) is displaying a description for "0001", which is "A" (refer to the database, Capture.PNG)