哪位大神能帮我看下代码哪里错了吗?

Death_wuying 2013-12-26 05:36:38
private void button3_Click(object sender, EventArgs e)
{
serach();
}
public void serach()
{
// sqlInit();
// Database conn = new Database();
connection = new OleDbConnection(ConnStr);
connection.Open();
string s = textBoxSelectName.Text;
string selectStudentInfo = "SELECT * FROM [Student] WHERE [姓名]='"+ textBoxSelectName +"'";
OleDbDataAdapter Adap = new OleDbDataAdapter(selectStudentInfo, connection);
DataSet data = new DataSet();
Adap.Fill(data,"Student");
DataSet ds = data;
dataGridViewSelectStudentManage.DataSource = ds.Tables["Student"];
connection.Close();

}
数据库的链接,添加都实现了,就是这个查询实现不了,输入名字的话,不出来结果,只出来一行空白。听说CSDN上的大神很多,特来求教!
...全文
92 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
hudsonhuang 2013-12-26
  • 打赏
  • 举报
回复
引用 15 楼 Death_wuying 的回复:
[quote=引用 14 楼 hudsonhuang 的回复:] [quote=引用 4 楼 Death_wuying 的回复:] [quote=引用 1 楼 hudsonhuang 的回复:] -_- string selectStudentInfo = "SELECT * FROM [Student] WHERE [姓名]='"+ textBoxSelectName +"'"; textBoxSelectName明显是textbox对象啊,好心调试一下啊
这个我在textBoxSelectName输入名字,然后查询,但结果不对啊![/quote] 我连吐槽的力气都没有了 [/quote] 不好意思啊!初学者!献丑了!总之,很感谢你们的帮助![/quote] 我只给10分 我突然有了吐槽的力气了。。。
Death_wuying 2013-12-26
  • 打赏
  • 举报
回复
引用 14 楼 hudsonhuang 的回复:
[quote=引用 4 楼 Death_wuying 的回复:] [quote=引用 1 楼 hudsonhuang 的回复:] -_- string selectStudentInfo = "SELECT * FROM [Student] WHERE [姓名]='"+ textBoxSelectName +"'"; textBoxSelectName明显是textbox对象啊,好心调试一下啊
这个我在textBoxSelectName输入名字,然后查询,但结果不对啊![/quote] 我连吐槽的力气都没有了 [/quote] 不好意思啊!初学者!献丑了!总之,很感谢你们的帮助!
hudsonhuang 2013-12-26
  • 打赏
  • 举报
回复
引用 4 楼 Death_wuying 的回复:
[quote=引用 1 楼 hudsonhuang 的回复:] -_- string selectStudentInfo = "SELECT * FROM [Student] WHERE [姓名]='"+ textBoxSelectName +"'"; textBoxSelectName明显是textbox对象啊,好心调试一下啊
这个我在textBoxSelectName输入名字,然后查询,但结果不对啊![/quote] 我连吐槽的力气都没有了
Death_wuying 2013-12-26
  • 打赏
  • 举报
回复
引用 12 楼 Sant11 的回复:
[string s = textBoxSelectName.Text;] 这里你设变量了。 把【textBoxSelectName】换成【textBoxSelectName.Text】一样的结果。如果用【textBoxSelectName.Text】 【string s = textBoxSelectName.Text;】就没有必要要。
恩恩,愚昧了!谢啦!
Sant11 2013-12-26
  • 打赏
  • 举报
回复
[string s = textBoxSelectName.Text;] 这里你设变量了。 把【textBoxSelectName】换成【textBoxSelectName.Text】一样的结果。如果用【textBoxSelectName.Text】 【string s = textBoxSelectName.Text;】就没有必要要。
Death_wuying 2013-12-26
  • 打赏
  • 举报
回复
引用 10 楼 guyuekkk11 的回复:
你按7楼的写 试试 应该没问题
恩,可以啦!谢啦!没分了!就不给你啦!
  • 打赏
  • 举报
回复
你按7楼的写 试试 应该没问题
Death_wuying 2013-12-26
  • 打赏
  • 举报
回复
引用 7 楼 Sant11 的回复:
string selectStudentInfo = "SELECT * FROM [Student] WHERE [姓名]='"+ s +"'";
恩恩,可以啦!额外话,为什么不能写textbox啊!
Death_wuying 2013-12-26
  • 打赏
  • 举报
回复
引用 5 楼 Sant11 的回复:
把【textBoxSelectName】换成s
大神太厉害了,呵呵!可以啦!谢啦!
Sant11 2013-12-26
  • 打赏
  • 举报
回复
string selectStudentInfo = "SELECT * FROM [Student] WHERE [姓名]='"+ s +"'";
Death_wuying 2013-12-26
  • 打赏
  • 举报
回复
引用 3 楼 guyuekkk11 的回复:
1楼说的也有可能出现,你看是不是那里出了问题。
那查询语句该怎么写,大神!
Sant11 2013-12-26
  • 打赏
  • 举报
回复
把【textBoxSelectName】换成s
Death_wuying 2013-12-26
  • 打赏
  • 举报
回复
引用 1 楼 hudsonhuang 的回复:
-_- string selectStudentInfo = "SELECT * FROM [Student] WHERE [姓名]='"+ textBoxSelectName +"'"; textBoxSelectName明显是textbox对象啊,好心调试一下啊
这个我在textBoxSelectName输入名字,然后查询,但结果不对啊!
  • 打赏
  • 举报
回复
1楼说的也有可能出现,你看是不是那里出了问题。
  • 打赏
  • 举报
回复
目测没有问题,你拿断点跟一下,把sql语句在数据库中运行一下看有没有结果。
hudsonhuang 2013-12-26
  • 打赏
  • 举报
回复
-_- string selectStudentInfo = "SELECT * FROM [Student] WHERE [姓名]='"+ textBoxSelectName +"'"; textBoxSelectName明显是textbox对象啊,好心调试一下啊

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧