F
FuhansPujiSaputra
Guest
Hi everyone, i wanna ask a question.
I want to display a description when the code in database are display at my program.
Here is my code:
UpdateDatas();
OleDbDataReader dReader;
OleDbConnection conn = new OleDbConnection(connectionString);
conn.Open();
OleDbCommand cmd = new OleDbCommand("SELECT DISTINCT
I want to display a description when the code in database are display at my program.
Here is my code:
UpdateDatas();
OleDbDataReader dReader;
OleDbConnection conn = new OleDbConnection(connectionString);
conn.Open();
OleDbCommand cmd = new OleDbCommand("SELECT DISTINCT
Code:
FROM [Data]", conn);
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();
private void UpdateDatas()
{
OleDbDataReader dReader;
OleDbConnection conn = new OleDbConnection(connectionString);
conn.Open();
OleDbCommand cmd = new OleDbCommand("SELECT DISTINCT [Description] FROM [Data] WHERE [Code]=@Code", conn);
cmd.Parameters.Add("Code", System.Data.OleDb.OleDbType.Integer);
cmd.Parameters["Code"].Value = this.textBoxDescContainer[0][1].Text;
dReader = cmd.ExecuteReader();
while (dReader.Read())
{
this.textBoxDescContainer[0][1].Text = dReader["Description"].ToString();
}
dReader.Close();
conn.Close();
}
What i want is to display a description based on my database when the code is selected:
Here is the images:
[IMG]http://test.computerhelp.forum/data/MetaMirrorCache/59a40570b1c43c467b7d0555cf625184._.png[/IMG]
[IMG]http://test.computerhelp.forum/data/MetaMirrorCache/d6d234b82f823b71a2473af40e32e125._.png[/IMG]
When the code is "0001", because i used "PadLeft 0" on my code, so the "1" will become "0001", and when the "0001" is selected, the description also come out, which is "A". But i got nothing, when i select the "0001" like the image above, the description not come out.
Please help me
Thank you
[url="http://social.msdn.microsoft.com/Forums/en-US/11fdd1cb-24a2-4dae-bb56-0f80f4472362/displaying-a-description-based-on-code-in-database"]Continue reading...[/url]