您的位置:首页 > 编程语言 > ASP

[Asp.Net]实现提取数据到table中 不用服务器控件

2010-04-16 09:43 344 查看
1.后台方法
public string id;
public string usercode;
public void tbalelist(string strsql)
{
string str = string.Empty;
DBCon OAcon = new DBCon();
SqlConnection myConn = new SqlConnection(OAcon.getOAcon());
myConn.Open();
SqlCommand sc = new SqlCommand(strsql, myConn);
SqlDataReader sr = sc.ExecuteReader();
if(sr.Read())
{
id=sr[0].ToString();
usercode = sr[1].ToString();
}
sr.Close();
myConn.Close();

}
2.前台
<table align="center" border="0" cellpadding="5" cellspacing="1" width="100%">
<tr>
<td class="hback" width="5%">
<font color="#cc3300"><b>ID</b></font></td>
<td class="hback" width="10%">
<font color="#cc3300"><b>张号</b></font></td>

</tr>
<tr>
<td class="hback" width="5%"><%= id %></td>
<td class="hback" width="10%"><%= usercode %></td>
</tr>
</table>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐