| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 679 人关注过本帖
标题:大家瞧瞧哪里错了???
只看楼主 加入收藏
angie8
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2005-4-29
收藏
 问题点数:0 回复次数:4 
大家瞧瞧哪里错了???

public void ShowStu()

{

string connstr,selectCmd;

connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=学生成绩管理系统.mdb";

selectCmd="select 学号,姓名,性别,年级名称,班级名称 from 学生表 where 年级名称=comboBox1.Text and 班级名称=comboBox2.Text order by 学号";

OleDbConnection conn;

OleDbDataAdapter myAdapter;

conn=new OleDbConnection(connstr);

myAdapter=new OleDbDataAdapter(selectCmd,conn);

myAdapter.Fill(myDataSet,"学生表");

dataGrid1.DataSource=myDataSet;

dataGrid1.DataMember="学生表";

//更改(隐藏)dataGrid中显示的列

DataGridTableStyle ts =new DataGridTableStyle();

ts.MappingName=dataGrid1.DataMember;

dataGrid1.TableStyles.Add(ts);

dataGrid1.TableStyles[0].GridColumnStyles[0].Width = 55;

dataGrid1.TableStyles[0].GridColumnStyles[1].Width = 60;

dataGrid1.TableStyles[0].GridColumnStyles[2].Width = 0;

dataGrid1.TableStyles[0].GridColumnStyles[3].Width = 0;

dataGrid1.TableStyles[0].GridColumnStyles[4].Width = 0;

Binding BindId=new Binding("Text",dataSet12,"学生表.学号");

Binding BindName=new Binding("Text",dataSet12,"学生表.姓名");

Binding BindSex=new Binding("Text",dataSet12,"学生表.性别");

txtId.DataBindings.Add(BindId);

txtName.DataBindings.Add(BindName);

txtSex.DataBindings.Add(BindSex);

Bm=this.BindingContext[dataSet12,"学生表"];

CheckBm();

}

这段代码运行的时候会出现数据加载错误

搜索更多相关主题的帖子: 姓名 管理系统 public where 
2005-05-09 22:25
angie8
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2005-4-29
收藏
得分:0 
为什么用sql这样查询就会出错呢?
如果把where 条件去掉的话就可以运行的
2005-05-09 22:28
diaowubin
Rank: 1
等 级:新手上路
帖 子:20
专家分:0
注 册:2005-4-23
收藏
得分:0 
错在这里: selectCmd="select 学号,姓名,性别,年级名称,班级名称 from 学生表 where 年级名称=comboBox1.Text and 班级名称=comboBox2.Text order by 学号"; 你的SQL没过关 再学学吧 得把comboBox1.TextcomboBox2.Text 传递给SqlCommand的参数,这样直接写是不行的!

2005-05-10 19:47
angie8
Rank: 1
等 级:新手上路
帖 子:17
专家分:0
注 册:2005-4-29
收藏
得分:0 
哈哈
不是啦
我自己找到原因了
combobox1.Text要用单引号括起来
2005-05-10 20:47
zhb1875
Rank: 2
等 级:论坛游民
威 望:1
帖 子:25
专家分:72
注 册:2009-10-22
收藏
得分:0 
你的查询条件写错了。。。 where 年级名称=comboBox1.Text and 班级名称=comboBox2.Text
这么写 where 年级名称='"+comboBox1.Text+"' and 班级名称='"+comboBox2.Text+"'
2010-07-03 11:55
快速回复:大家瞧瞧哪里错了???
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019136 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved