zoukankan
html css js c++ java
使用OleDbDataReader 或sqldatareader 连数据库
<%
@ Page Language
=
"
C#
"
Debug
=
"
true
"
%>
<%
@Import NameSpace
=
"
System.Data
"
%>
<%
@Import NameSpace
=
"
System.Data.OleDb
"
%>
<%
string
StrCon
=
"
Provider=Microsoft.Jet.OleDb.4.0;Data Source=
"
+
Server.MapPath(
"
data.mdb
"
);
//
建立数据库连接串,此处为OLEDB连接方式,另外还有ado连接方式
string
strSQL
=
"
SELECT * FROM main order by 编号 desc
"
;
//
sql查询,查找所有新闻记录,把它们按编号降序排序.
OleDbConnection MyConnection
=
new
OleDbConnection(StrCon);
//
建立OLEDB connection连接对象
OleDbCommand myCommand
=
new
OleDbCommand(strSQL,MyConnection);
//
建立OLEDB command连接对象
OleDbDataReader myDataReader
=
null
;
//
建立数据读取对象
myCommand.Connection.Open();
//
打开connection连接
myDataReader
=
myCommand.ExecuteReader();
//
为数据读取对象建立数据源
myDataReader.Read();
//
开始读取数据源
Response.Write(
"
dnews=
"
+
myDataReader[
"
新闻
"
].ToString());
//
新闻输出,格式: dnew=新闻内容 &dtime=更新时间
Response.Write(
"
&dtime=
"
+
myDataReader[
"
更新时间
"
].ToString());
myCommand.Connection.Close();
//
关闭connection连接
%>
查看全文
相关阅读:
English Voice of <<Cups>>
【线段树】奶牛排队(USACO 2007 January Gold)
【线段树】买水果
【线段树】卫星覆盖(NOI97)-矩阵切割
插入排序 (Insertion Sort)
选择排序 (Selection Sort)
springboot整合redis
redis入门及相关API
mycat配置文件的详细介绍
redis常用命令
原文地址:https://www.cnblogs.com/yeagen/p/1330922.html
最新文章
散点图的绘制
代码:注册登录系统
python第三方模块的安装方法
异常值的处理:try & 爬虫初识
time & datetime
shutil模块与datetime模块 & 文件的解压及压缩
字节类型 & pickl与json
3、docker 修改加速器
8、windows 编写的shell脚本复制到Linux环境下运行
7、Linux 的启动过程
热门文章
6、Linux 的七个运行级别
11、Linux git clone 报错:git-upload-pack: command not found
10、CentOS-make: command not found
9、URI is not registered (Settings | Languages & Frameworks | Schemas and DTDs
8、Failed to get D-Bus connection: Operation not permitted
7、Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
6、Operation inconsistent with current state
django的Cookie Session
django
NAS--群辉220+ 初始化
Copyright © 2011-2022 走看看