日期:2014-05-17 浏览次数:20418 次
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
public partial class _0212OLEDB简单读取 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string str_connection="Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=D:\\SQLSERVER2012\\MSSQL11.MSSQLSERVER\\MSSQL\\DATA\\View.mdf";
OleDbConnection cnn;
OleDbCommand cmd;
OleDbDataReader datar;
cnn=new OleDbConnection(str_connection);
cnn.Open();
string str_sql="select news_ttl from news";
cmd=new OleDbCommand(str_sql,cnn);
datar=cmd.ExecuteReader();
while(datar.Read())
{
div_reader.InnerHtml += datar["news_ttl"].ToString() + "<br/>";
}
cnn.Close();
}
}