|
| JScript.Net 之 SqlDataReader读取数据 |
|
作者:supreme 文章来源:不详 点击数: 更新时间:2007-11-14 12:59:54  |
|
<%@import namespace="System.Data.SqlClient"%>
var db : String = "server=10.1.0.1;uid=sa;pwd=123;database=db"; var sql : String = " select * from table ";
var rs = SqlDataReader; var conn : SqlConnection = new SqlConnection(db); var cmd : SqlCommand = new SqlCommand(sql,conn); try{
conn.Open(); rs = cmd.ExecuteReader(); if (rs.HasRows){ //Founded. }else{ //Not Found.
while(rs.Read()){ Response.Write(rs["id"] .ToString()); } } rs.Close(); conn.Close(); }catch(e){ Response.Write("ERROR!"); }finally{ cmd.Dispose(); conn.Dispose(); } %>
|
|
| 文章录入:mintao 责任编辑:mintao |
|
|
上一篇文章: VB/ASP 调用 SQL Server 的存储过程 下一篇文章: SQL中两台服务器间使用连接服务器 |
|
|
| 【字体:小 大】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口】 |
|