C#数据库连接中的代码问题

[复制链接]
查看11 | 回复2 | 2010-3-31 17:24:16 | 显示全部楼层 |阅读模式
read.Read()之后,还要用索引器来访问值: if (read.Read()) {
string s= read["列名"] as string; // 如果这个列是一个char型的话。
decimal d = (decimal)read["金额"];
// 下面是考虑了null值的情况的代码。
decimal? d = (read["金额"] == DBNull.Value ? null: (decimal)read["金额"]);}
回复

使用道具 举报

千问 | 2010-3-31 17:24:16 | 显示全部楼层
string strsql = "select * from tb_lord where lord_id='"+strSn+"' and lord_pwd='"+strPwd+"'";
回复

使用道具 举报

千问 | 2010-3-31 17:24:16 | 显示全部楼层
你的意思是不是没有进入if语句里面 if (read.Read())此处read函数不能读取'strSn''strPwd'
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行