//创建一个试图
create view View_SelectAllInfo
as
select name as '姓名',id as '编号',sex as '性别' from UserInfo
go//C#中进行查询string sql = "View_SelectAllInfo";
sqlconnection conn = new sqlconnection(连接字符串);
sqlcommand command = new sqlcommand(sql,conn);
sqldataReader dataReader = command.ExecuteReader();
//读出列的值将它放入创建的对象中
while(dataReader.read())
{
User user = new User();
user.Name = dataReader[[color=#00FF00]?填什么];
}[/color]我的问题就是 上面的DataReader 对象读出的值怎么取出来
因为这里用的是试图,我不知道通过什么来取值。请大家指点!谢谢!
create view View_SelectAllInfo
as
select name as '姓名',id as '编号',sex as '性别' from UserInfo
go//C#中进行查询string sql = "View_SelectAllInfo";
sqlconnection conn = new sqlconnection(连接字符串);
sqlcommand command = new sqlcommand(sql,conn);
sqldataReader dataReader = command.ExecuteReader();
//读出列的值将它放入创建的对象中
while(dataReader.read())
{
User user = new User();
user.Name = dataReader[[color=#00FF00]?填什么];
}[/color]我的问题就是 上面的DataReader 对象读出的值怎么取出来
因为这里用的是试图,我不知道通过什么来取值。请大家指点!谢谢!
解决方案 »
- C#DLL的相关问题 大侠入
- 如何让下载的CAB文件中的msi程序能安装成功
- 问一下各位大大哦!socket。帮我解决下,上图了!
- 有没有excel插件直接把Excel绑定到页面上来进行操作
- 请问,谁晓得,用程序流程图,怎么表达出,c#,try {} catch 这样的怪异处理
- 网页二次开发用到一个打印控件,安装失败。
- 如何把table中的数据全部提交到数据库中?
- 用System.Web.HttpUtility.UrlEncode方法编码过的字符串,怎样反编码得到原来的字符串?
- 问高手,下面的代码怎么解释(解说详细点)
- 新手提问!
- 关于datagridviewcolumn的重载,要实现一些功能?(顶者有分)
- 如何将dataset中的table导入数据库,前提是不知道该table的结构,而且数据库中也没有对应的表。
user.Name = dataReader[0];
{
User user = new User();
user.Name = dataReader["姓名"]?填什么];
}看看能不能取得
不能取得就用数字dataReader[0]
string sql = "View_SelectAllInfo";
sqlconnection conn = new sqlconnection(连接字符串);
sqlcommand command = new sqlcommand(sql,conn);
sqldataReader dataReader = command.ExecuteReader();
//读出列的值将它放入创建的对象中
while(dataReader.read())
{
User user = new User();
user.Name = dataReader["姓名"].ToStrong();
}