using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Configuration;
using System.Data;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string sqlcmd ="select top 20 id,test_time,title,summary from test";
}
private void ConnectDB(string ConnectionString,string sqlcmd)
{
SqlConnection Conn = new SqlConnection();
Conn.ConnectionString = WebConfigurationManager.ConnectionStrings[ConnectionString].ConnectionString;
SqlDataReader dr = null;
SqlCommand cmd = new SqlCommand(sqlcmd,Conn);
try
{
Conn.Open();
dr = cmd.ExecuteReader();
while (dr.Read())
{
}
}
catch (Exception ex)
{
Response.Write("<b>Error Message----</b>" + ex.ToString());
}
finally {
if (dr != null) {
cmd.Cancel();
dr.Close();
}
if (Conn.State == ConnectionState.Open) {
Conn.Close();
Conn.Dispose();
}
}
}
}
沒有留言:
張貼留言