永利集团304com:资料管理器

using System; using System.Collections.Generic; using
System.ComponentModel; using System.Data; using System.Drawing; using
System.Text; using System.Windows.Forms;

    }

private void MainForm_Load(object sender, EventArgs e) {
//枚举本地网络内所有可用SqlServer实例 SqlDataSourceEnumerator instance =
SqlDataSourceEnumerator.Instance; //返回
//—————————————————————————-
// ServerName|服务器的名称
//—————————————————————————-
// InstanceName|服务器实例的名称。如果服务器作为默认实例运行,则为空白
//—————————————————————————-
// IsClustered|指示服务器是否属于群集
//—————————————————————————-
// Version|服务器的版本(SQLServer2000为8.00.x,SQLServer2005为9.00.x)
//—————————————————————————-
DataTable dt = instance.GetDataSources(); //绑定
cboServerList.DataSource = CreateCboDataSource(dt); }

        {

核心提示:using System;using System.Collections.Generic;using
System.ComponentModel;using System.Data;using System.Drawing;using
System.Text;using System.Windows.Forms;//所引入的命名空间

SqlHelper

return list; } } }

            }

foreach (DataRow dr in dt.Rows) { //只取ServerName
list.Add(dr[0].ToString()); }

           using (SqlConnection con=new SqlConnection (conStr))

//所引入的命名空间 using System.Data.Sql;

       public int Areaid { get; set; }

namespace EnumSqlServer { public partial class MainForm : Form { public
MainForm() { InitializeComponent(); }

       /// <returns></returns>

/// summary /// 取得ComBox的数据源 /// /summary /// param name=dt/param
/// returns/returns private Liststring CreateCboDataSource(DataTable dt)
{ Liststring list = new Liststring();

                       com.Parameters.AddRange(pms);

                         ProvinceItem item = new ProvinceItem();

            //2.遍历将获取到的数据绑定到TreeNodeCollection节点集合中

    {

        {

                }

{

using System.Collections.Generic;

                int areaId = item.AreaId;

        {

                       throw;

                        item.AreaPid = reader.GetInt32(2);

           }

       private static readonly string conStr =
ConfigurationManager.ConnectionStrings[“constr”].ConnectionString;

            itemDefault.AreaName = “请选择”;

namespace _02省市联动

 

using System.Drawing;

            comboBox1.Items.Insert(0, itemDefault);

               adapter.Fill(dt);

           using (SqlConnection con = new SqlConnection(conStr))

                   

                   {

                        ProvinceItem item = new ProvinceItem();

using System.ComponentModel;

namespace _02省市联动

}

                    while (reader .Read ())

        }

 

            //List<Area> listProvince = GetSubItemByParentId(0);

            {

using System;

        public int AreaPid{get ;set;}

            }

        public int AreaId {get ;set;}

                }

                        item.AreaId = reader.GetInt32(0);

using System.Text;

       public int AreaPid { get; set; }

                    {

       //连接字符串

    }

                   con.Open();

        /// <param name=”sender”></param>

using System.Text;

 

            comboBox2.Items.Clear();

               //如何添加参数

            LoadProvince();

                   

{

       /// 封装返回一个单个值的方法

using System;

                    }

 

       public static int ExecuteQuery(string sql,params SqlParameter[]
pms)

            }

using System.Collections.Generic;

                   }

           //加载省份信息到第一个ComboBox

            //}

            itemDefault.AreaId = -1;

            foreach (var item in listCity )

    

                       com.Parameters.AddRange(pms);

}

                        model.AreaName = reader.GetString(1);

                    while (reader.Read())

       public string AreaName { get; set; }

            string sql = “select * from TblArea where AreaPId  =0”;

                       con.Close();

            {

        private void button1_Click(object sender, EventArgs e)

        {

                if (reader .HasRows )

            ProvinceItem itemDefault = new ProvinceItem();

               using (SqlCommand com=new SqlCommand (sql,con))

               {

 

}

       {

using System.Collections.Generic;

        private void LoadDataToTree(TreeNodeCollection
treeNodeCollection, int pid)

       /// </summary>

        private void Form1_Load(object sender, EventArgs e)

{

                if (reader .HasRows)

}

        /// <param name=”e”></param>

        private void LoadCity(int areaId)

            comboBox2.Items.Insert(0, itemDefault);

                   return com.ExecuteNonQuery();

        }

            string sql = “select * from TblArea where AreaPId=@aid”;

            ////1.把所有的省份及直辖市加载到TreeView的根节点上

                TreeNode node = treeNodeCollection.Add(item.AreaName);

                        item.AreaPid = reader.GetInt32(2);

           {

                   }

                {

using System.Text;

                    while(reader .Read())

using System.Collections.Generic;

可空值类型,资料管理器,多条件查询,Case

            itemDefault.AreaId = -1;

       /// <summary>

            using (SqlDataReader reader = SqlHelper.ExecuteReader(sql,
new SqlParameter(“@aid”, areaId)))

省市联动

                   }

                        item.AreaName = reader.GetString(1);

       public static object ExecuteScalar(string sql,params
SqlParameter[] pms)

            }

        //封装一个方法,根据父ID查询下面的所有子项

        }

using System;

                   {

                {

               {

 

            using (SqlDataReader reader=SqlHelper .ExecuteReader(sql))

            //{

            //递归将省市加载到TreeView中

                   }

        {

        }

    }

using System.Windows.Forms;

            //获取当前用户选择的项

               {

第20课-数据库开发及ado.net

       /// <summary>

        {

            //1.根据指定的Pid获取该城市下的子城市

                //返回刚刚添加的这个节点

                        comboBox1.Items.Add(item);

            //foreach (Area  item in listProvince)

    {

           }

                       com.Parameters.AddRange(pms);

        }

发表评论

电子邮件地址不会被公开。 必填项已用*标注