问题描述:

I am trying to get a simple function in my program to find data in a DB and bring it back. I am doing this using two text boxes. Its a translation function so when you search for one word in the first text box it should display the translated/matched word from the DB in the second texbox. Cant get it to work, heres my code anyway...

string strProvider = @"PATH is here";

string strSql = "SELECT jpn FROM Vocab WHERE eng like '" + textBox1.Text + "%'";

OleDbConnection newConn = new OleDbConnection(strProvider);

OleDbCommand dbCmd = new OleDbCommand(strSql, newConn);

newConn.Open();

dbCmd.CommandType = CommandType.Text;

OleDbDataReader dr = dbCmd.ExecuteReader();

while (dr.Read())

{

textBox2.Text = dr.GetString(0);

}

相关阅读:
Top