c#我想用两个textbox中的任意一个textbox在数据库中查询然后显示在另一个里我下面的代码需要怎么修改 100

stringcondtr="server=localhost;UserId=root;password=zyz;Database=cd";MySqlConnectionm... string condtr = "server=localhost;User Id=root;password=zyz;Database=cd";
MySqlConnection mycon = new MySqlConnection(condtr);
mycon.Open();
MySqlCommand mycmd = new MySqlCommand("select * from cd1 where 英文='" + textBox1.Text + "'", mycon);
MySqlDataReader mydr = mycmd.ExecuteReader();
if (mydr.HasRows)
{
while (mydr.Read())
{
textBox2.Text = mydr["英文"] + "\n";
DataGridViewRow dgvr = new DataGridViewRow();
dgvr.CreateCells(dataGridView1, new object[] { "查询", textBox1.Text, textBox2.Text });
dataGridView1.Rows.Add(dgvr);
}
Console.ReadLine();
mycon.Close();
}
else
{
MessageBox.Show("词典暂无此单词");
}
展开
 我来答
heart阿飞55
2018-05-13 · TA获得超过1086个赞
知道大有可为答主
回答量:3030
采纳率:82%
帮助的人:542万
展开全部
string i = "select sum(toolNumber) from mtctoolstable where tooltime between year1+month1 and year2+month2 and toolsign=0 and toolName=toolName"; 第二个toolName应该是个参数吧,应该 string i = "select sum(toolNumber) from mtctoolstable where tooltime between year1+month1 and year2+month2 and toolsign=0 and toolName='"+toolName+"'"; 然后你的year1+month1 你看下结果是什么,是日期的格式吗?应该不是吧。 格式相同才能比较撒。 如果2008-1-1和20081 怎么比较。
追问
我现在有另一个问题 你有时间吗
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式