社区
C#
帖子详情
执行完oleDbCommand1.ExecuteReader()后
molester
2002-07-01 03:17:55
如何把找到的记录读出来?如果没有找到合适的记录,通过什么可以判断出它是空的呢?
...全文
73
7
打赏
收藏
执行完oleDbCommand1.ExecuteReader()后
如何把找到的记录读出来?如果没有找到合适的记录,通过什么可以判断出它是空的呢?
复制链接
扫一扫
分享
转发到动态
举报
写回复
配置赞助广告
用AI写文章
7 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
hbxtx
2002-07-01
打赏
举报
回复
同意bearbaba的。条件里的字符要用单引号
bearbaba
2002-07-01
打赏
举报
回复
molester() 说的是webform的处理方法,在winForm中可以使用如下方法
.....
myCommand.CommandText = "SELECT CountryID FROM TableCountry WHERE CountryName = '"+textBox1.Text+"'";
myConnection.Open();
SqlDataReader myReader = myCommand.ExecuteReader();
// 申请String变量,以获取国家代码
int iNationalCode = 0;
//myReader = myCommand.ExecuteReader();
myReader.Read();
// 获取符合条件记录的第0个字段的字段值
iNationalCode = (int)myReader.GetSqlInt32(0);
myConnection.Close();
....
如果紧紧试向取得是否有这条记录存在可以使用如下的办法 :
....
myConnection.Open();
// 获取返回值,并转换成int型
iRecieveExist = (int)myCommand.ExecuteScalar();
// 如果iReceieveExist的值为0,说明此国家不存在,执行插入操作
....
molester
2002-07-01
打赏
举报
回复
string sqql="select name,password from infor where name=\"" + TextBox1.Text + "\" and password=\"" + TextBox2.Text + "\"";
OleDbCommand com=new OleDbCommand(sqql,OleDbConnection) ;
OleDbConnection.Open();
OleDbDataReader myReader;;
myReader = com.ExecuteReader();
if (myReader.Read())
{
Session["name"]=TextBox1.Text;
Session["password"]=TextBox2.Text;
Server.Transfer("WebForm2.aspx");
}
hbxtx
2002-07-01
打赏
举报
回复
估计是你的查询条件有问题,把代码贴出来看看.
triout
2002-07-01
打赏
举报
回复
那是你的SQL语句的问题了。
SqlDataReader sr;
string select=查询条件;//
SqlCommand sc=new SqlCommand(select,sqlConnection1);
sr=sc.ExecuteReader();
while(sr.Read())
{
//对数据进行处理。
}
molester
2002-07-01
打赏
举报
回复
运行后提示“标准表达式中数据类型不匹配。”
指示出问题的行是 “sr=sc.ExecuteReader();
”,请问是什么原因,如何解决?
hbxtx
2002-07-01
打赏
举报
回复
SqlDataReader sr;
string select=查询条件;//
SqlCommand sc=new SqlCommand(select,sqlConnection1);
sr=sc.ExecuteReader();
if(sr.Read())
{
//找到
}
else
{
//没找到
}
CrystalReport1.rpt ,DataSet.xsd,crystalReportView
er
1水晶报表,以及向文本框对象传值 C# .NET FRAMEWORK 源代码 决定对您有用
//表名的写法也应注意不同,对应的excel表为sheet1,在这里要在其后加美元符号$,并用中括号 Cmd = new
OleDb
Command
(strSql, Con);//建立要
执行
的命令
OleDb
Data
Read
er
read
= null; DataSet ds = new ...
Settingshezhi.settings reportView
er
1 Report1.rdlc DataSet.xsd C# .NET FRAMEWORK 源代码
//表名的写法也应注意不同,对应的excel表为sheet1,在这里要在其后加美元符号$,并用中括号 Cmd = new
OleDb
Command
(strSql, Con);//建立要
执行
的命令
OleDb
Data
Read
er
read
= null; DataSet ds = new ...
c#中
execute
read
er
执行
查询示例分享
Execute
Read
er
执行
查询实例
Execute
Read
er
方法存在的目的只有一个:尽可能快地对数据库进行查询并得到结果。
Execute
Read
er
返回一个Data
Read
er
对象:如果在Sql
Command
对象中调用,则返回SqlData
Read
er
;如果在...
十天学会ASP.net--我认为ASP.NET比ASP难很多,希望大家做好准备
大家可以看到我们首先是连接数据库然后打开,对于select的命令,我们申明一个
OleDb
Command
来
执行
之,然后再申明一个
OleDb
Data
Read
er
,来读取数据,用的是
Execute
Read
er
(),objData
Read
er
.
Read
()就开始读取了,在输出...
vb.net mysql
execute
read
er
_VB.NET访问ACCESS数据库,查询时,提示dr = cmd.
Execute
Read
er
()至少一个参数没被指定值...
ImportsSystem.Data.
OleDb
PublicClassForm1PrivateSubButton1_Click(ByValsend
er
AsSystem.Object,ByValeAsSystem.EventArgs)HandlesButton1.ClickDimconAsNew
OleDb
Connectioncon.Conn...Imports System.Data.
OleDb
Pu...
C#
110,533
社区成员
642,574
社区内容
发帖
与我相关
我的任务
C#
.NET技术 C#
复制链接
扫一扫
分享
社区描述
.NET技术 C#
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧
+ 用AI写文章