当前位置:中国站长下载文章中心网页编程.NET编程 → 用ASP.NET写你自己的代码生成器

用ASP.NET写你自己的代码生成器

减小字体 增大字体 作者:不详  来源:不详  发布时间:2006-8-14 9:49:26
nString = "user id="+this.txtUserName.Text+
   ";password="+this.txtPassword.Text+
   ";initial catalog="+this.DropDownList3.SelectedItem.Text+
   ";data source="+this.txtServerName.Text;
   SqlCommand m_Scmd = new SqlCommand("sp_columns",m_Scon);
   m_Scmd.CommandType = CommandType.StoredProcedure;
   SqlParameter myParm = m_Scmd.Parameters.Add("@table_name",SqlDbType.VarChar,100);
   myParm.Value = this.DropDownList1.SelectedItem.Value;
   m_Scon.Open();
   SqlDataReader m_Sdr = m_Scmd.ExecuteReader();
   this.DropDownList2.Items.Clear();
   while(m_Sdr.Read())
   {
   ListItem m_LI = new ListItem();
   m_LI.Text = m_Sdr["COLUMN_NAME"].ToString();
   m_LI.Value = m_Sdr["COLUMN_NAME"].ToString();
   this.DropDownList2.Items.Add(m_LI);
   }
   m_Sdr.Close();
   m_Scon.Close();
   }
   }
   catch
   {
   if(m_Scon.State.ToString().ToUpper()=="OPEN")
   {
   m_Scon.Close();
   }
   }
   }
  
   #endregion
  
   #region Show All DataBase Button2_Click
   /// <summary>
   /// 显示所有数据库
   /// </summary>
   /// <param name="sender"></param>
   /// <param name="e"></param>
   private void Button2_Click(object sender, System.EventArgs e)
   {
   try
   {
   m_Scon.ConnectionString = "user id="+this.txtUserName.Text+
   ";password="+this.txtPassword.Text+
   ";data source="+this.txtServerName.Text;
   SqlCommand m_Scmd = new SqlCommand("sp_databases",m_Scon);
   m_Scmd.CommandType = CommandType.StoredProcedure;
   m_Scon.Open();
   SqlDataReader m_Sdr = m_Scmd.ExecuteReader();
   this.DropDownList1.Items.Clear();
   while(m_Sdr.Read())
   {
   ListItem m_LI = new ListItem();
   m_LI.Text = m_Sdr["DATABASE_NAME"].ToString();
   m_LI.Value = m_Sdr["DATABASE_NAME"].ToString();
   this.DropDownList3.Items.Add(m_LI);
   }
   m_Sdr.Close();
   m_Scon.Close();
   }
   catch
   {
   if(m_Scon.State.ToString().ToUpper()=="OPEN")
   {
   m_Scon.Close();
   }
   }
   }
  
   #endregion
  #region Make Form
   /// <summary>
   /// 生成表单项
   /// </summary>
   /// <param name="sender"></param>
   /// <param name="e"></param>
   private void Button3_Click(object sender, System.EventArgs e)
   {
   if(this.DropDownList1.SelectedIndex!=-1)
   {
   m_Scon.ConnectionString = "user id="+this.txtUserName.Text+
   ";password="+this.txtPassword.Text+
   ";initial catalog="+this.DropDownList3.SelectedItem.Text+
   ";data source="+this.txtServerName.Text;
   SqlCommand m_Scmd = new SqlCommand("sp_columns",m_Scon);
   m_Scmd.CommandType = CommandType.StoredProcedure;
   SqlParameter myParm = m_Scmd.Parameters.Add("@table_name",SqlDbType.VarChar,100);
   myParm.Value = this.DropDownList1.SelectedItem.Value;
   m_Scon.Open();
   SqlDataReader m_Sdr = m_Scmd.ExecuteReader();
   string ColName = "";
   string ColType = "";
   while(m_Sdr.Read())
   {
   ColName = m_Sdr["COLUMN_NAME"].ToString();
   ColType = m_Sdr["TYPE_NAME"].ToString();
   }
   m_Sdr.Close();
   m_Scon.Close();
   }
   }
   #endregion
  
   #region Make object
   /// <summary>
   /// 生成实体
   /// </summary>
   /// <param name="sender"></param>
   /// <param name="e"></param>
   private void Button4_Click(object sender, System.EventArgs e)
   {
   if(this.DropDownList1.SelectedIndex!=-1)
   {
   m_Scon.ConnectionString = "user id="+this.txtUserName.Text+
   ";password="+this.txtPassword.Text+
   ";initial catalog="+this.DropDownList3.SelectedItem.Text+
   ";data source="+this.txtServerName.Text;
   SqlCommand m_Scmd = new SqlCommand("sp_columns",m_Scon);
   m_Scmd.CommandType = CommandType.StoredProcedure;
   SqlParameter myParm = m_Scmd.Parameters.Add("@table_name",SqlDbType.VarChar,100);
   myParm.Value = this.DropDownList1.SelectedItem.Value;
   m_Scon.Open();
   SqlDataReader m_Sdr = m_Scmd.ExecuteReader();
   string TableNa

上一页  [1] [2] [3] [4] [5]  下一页