我现在工作了一个小时也许 6 个小时我无法让它工作请告诉我缺少什么?
因此,例如,我在这里有客户 Warren Buffet(他只是一个例子:D),如果我在 txtbox 上搜索他的名字,并且 sqldatabase 在数据行上找到他的名字,那么 Wafrren Bufet 数据将被添加到 DataGridView。
这是代码!
private void button2_Click(object sender, EventArgs e)
{
MySqlConnection connection = null;
string hostname = "localhost";
string database = "aparece_hoteldb";
string username = "root";
string password = "";
connection = new MySqlConnection("host=" + hostname +
";database=" + database +
";username=" + username +
";password=" + password + ";");
string query = "select * from reservations " +
"where Client like '%" + txtSearch.Text + "%' OR " +
"ClientNumber like '%" + txtSearch.Text + "%' OR " +
"RoomNumber like '%" + txtSearch.Text + "%' OR " +
"ClientRoomType like '%" + txtSearch.Text + "%' OR " +
"AddonService like '%" + txtSearch.Text + "%' OR "+
"TotalHotelRate '%" + txtSearch.Text + "%'";
connection.Open();
List<string>[] detailList = a.mysqlSelect(query);
for (int i = 0; i < detailList.Length; i++)
{
dgvUser.Rows.Add(detailList[i][0], detailList[i][1], detailList[i][2], detailList[i][3], detailList[i][4]);
}
}
}
}
这是图像!
![在此处输入图像描述][1]