再提treeview问题
开贴再提问????????
运行提示:超时时间已到。超时时间已到,但是尚未从池中获取连接。出现这种情况可能是因为所有池连接均在使用,并且达到了最大池大小。
表结构如下:
ID char 10
DETAIL varchar 50
NAME varchar 50
以下是我最新的代码:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Configuration;
public partial class Default9 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
AddTreeView(1, (TreeNode)null);
}
}
protected void AddTreeView(Int64 ID, TreeNode tn)
{
string CustomerDataConnectionString = System.Configuration.ConfigurationSettings.AppSettings[ "ConnectionString "];
SqlConnection objConn = new SqlConnection(CustomerDataConnectionString);
String strCmd = "select DETAIL,NAME from AAAA where ID= " + ID;
SqlCommand objCmd = new SqlCommand();
objCmd.Connection = objConn;
objConn.Open();
objCmd.CommandText = strCmd;
SqlDataReader objDR = objCmd.ExecuteReader();
while (objDR.Read())
{
if (tn == null)
{
TreeNode myNode = new TreeNode();
myNode.Text = objDR[ "DETAIL "].ToString().Trim();
myNode.Value = objDR[ "NAME "].ToString().Trim();