private void Bind(string txt) { string sql = string.Format("select*from Good"); if (this.comboBox1.Text != string.Empty) { sql += string.Format(" where [Good-name]='{0}'",txt); sql += string.Format(" where [Good-age]='{0}'", txt); sql += string.Format(" where [Good-gender]='{0}'", txt); sql += string.Format(" where [Good-qq]='{0}'", txt); sql += string.Format(" where [Good- phone]='{0}'", txt); sql += string.Format(" where [Good-wechat]='{0}'", txt); sql += string.Format(" where [Good-date]='{0}'", txt); } DataTable dt = DBHelper.getTable(sql); this.dataGridView1.DataSource = dt; this.comboBox1.SelectedIndex = 0; } private void 设置好友基本信息ToolStripMenuItem_Click(object sender, EventArgs e) { Form1 f1 = new Form1(); f1.Show(); this.Hide(); } private void Form2_Load(object sender, EventArgs e) { Bind(string.Empty); } private void 查询_Click(object sender, EventArgs e) { string cob = this.comboBox1.Text.Trim(); if (cob != string.Empty) { Bind(cob); } }
如何通过代码,进行传值,来定时提醒好友到了所预定的生日区间时,会通过Timer控件来提醒
,求帮忙!谢谢!
sql拼错了吧?
干嘛不用参数格式化查询呀!参考链接:http://www.cnblogs.com/hippieZhou/p/4486171.html