| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 507 人关注过本帖
标题:请教,如何将数据库技术和对象技术很好的结合起来。最好能给个例子。谢谢
只看楼主 加入收藏
zhmuyang
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-2-24
收藏
 问题点数:0 回复次数:1 
请教,如何将数据库技术和对象技术很好的结合起来。最好能给个例子。谢谢
请教,如何将数据库技术和对象技术很好的结合起来。最好能给个例子。谢谢
搜索更多相关主题的帖子: 数据库技术 如何 最好 
2006-02-24 09:38
islet
Rank: 12Rank: 12Rank: 12
等 级:贵宾
威 望:89
帖 子:6548
专家分:0
注 册:2005-1-28
收藏
得分:0 
http://bbs.bc-cn.net/bbs/dispbbs.asp?boardID=113&ID=46516&page=1

private void upBtn_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
if(NewsKindList.SelectedIndex > 0)
{
int nSelectedIndex = NewsKindList.SelectedIndex;
String id = NewsKindList.SelectedItem.Value.ToString();
SqlConnection myConnection = new SqlConnection(GlobalDB.DataBaseDB.ConnectionString);
String cmdText = "UPDATE NewsKinds SET KindOrder = KindOrder - 1 WHERE NewsKindID = " + id;
SqlCommand myCommand = new SqlCommand(cmdText,myConnection);
myConnection.Open();
myCommand.ExecuteNonQuery();
cmdText = "UPDATE NewsKinds SET KindOrder = KindOrder + 1 WHERE KindOrder = (SELECT KindOrder FROM NewsKinds WHERE NewsKindID = " + id + ") AND NewsKindID <> " + id;
myCommand = new SqlCommand(cmdText,myConnection);
myCommand.ExecuteNonQuery();
myConnection.Close();
BindNewsKindData();
NewsKindList.SelectedIndex = Math.Max(0,(nSelectedIndex - 1));
}
}
private void downBtn_Click(object sender, System.Web.UI.ImageClickEventArgs e)
{
if(NewsKindList.SelectedIndex < (NewsKindList.Items.Count - 1))
{
int nSelectedIndex = NewsKindList.SelectedIndex;
String id = NewsKindList.SelectedItem.Value.ToString();
SqlConnection myConnection = new SqlConnection(GlobalDB.DataBaseDB.ConnectionString);
String cmdText = "UPDATE NewsKinds SET KindOrder = KindOrder + 1 Where NewsKindID = " + id;
SqlCommand myCommand = new SqlCommand(cmdText,myConnection);
myConnection.Open();
myCommand.ExecuteNonQuery();
cmdText = "UPDATE NewsKinds SET KindOrder = KindOrder -1 WHERE KindOrder = (SELECT KindOrder FROM NewsKinds WHERE NewsKindID = " + id + ") AND NewsKindID <> " + id;
myCommand = new SqlCommand(cmdText,myConnection);
myCommand.ExecuteNonQuery();
myConnection.Close();
BindNewsKindData();
NewsKindList.SelectedIndex = Math.Min((NewsKindList.Items.Count - 1),(nSelectedIndex + 1));
}
}
2006-02-24 13:01
快速回复:请教,如何将数据库技术和对象技术很好的结合起来。最好能给个例子。谢 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.034551 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved