It's what I say

真羡慕你们,可以认识我

May
19

开发日志2

2008.05.19
10:58

主页显示图片与后台数据库连接成功

if (!IsPostBack)
{

//连接数据库
string strConn = @"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\065401_DB.mdf;Integrated Security=True;User Instance=True";
SqlConnection cn = new SqlConnection(strConn);
cn.Open();

string strSql = "Select PhotoTitle,PhotoUrl From Photos Where ([PopEnable] = 'True' )";

SqlCommand cmd = new SqlCommand(strSql, cn);
SqlDataReader dr = cmd.ExecuteReader();

//遍历数据库

while (dr.Read())
{
//标题
texts += dr["PhotoTitle"] + "|";
//链接
links += dr["PhotoUrl"] + "|";
//图片地址
pics += dr["PhotoUrl"] + "|";

//escape("images/333.jpg")

}
dr.Close();

//将字符串结尾的“|”去掉

texts = texts.Remove(texts.Length - 1);

pics = pics.Remove(pics.Length - 1);

links = links.Remove(links.Length - 1);




}

« 天佑国难 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

I'm...

日历

Categories

Comments

Previous

Powered By Z-Blog
Copyright by Ray © 2008-2012