日期:2013-05-29  浏览次数:20444 次


一、已有数据库(SQL)表,快速生成对应存储过程的工具。SQLPilot.exe

     SQLPilot.exe这个程序是CCF的一个朋友写的,具体请参考http://bbs.et8.net/bbs/showthread.php?t=534183

二、已有数据库表,快速生成列表、基本查询、高级查询、插入新行、删除、编辑asp.net页面的工具Asp.Net Maker

http://www.hkvstore.com/aspnetmaker/

     1.数据库操作类

以下是C#代码:

头文件:

using System;using System.Web.UI;using System.Globalization;using System.Data;using System.Data.SqlClient;namespace ns_db{public class c_db: UserControl{

 //******************************** //  返回数据库连接字符串 //********************************

 public string ewConnStr() {  return "Password=******;Persist Security Info=True;User ID=sa;Initial Catalog=******;Data Source=

(Local)"; } // End ewConnStr

 //****************************************************** //  返回一个 DataView 根据 Connection String & SQL //******************************************************

 public DataView ewDataView(string sConn, string sSQL) {  try  {

   // Create a new Connection Object   SqlConnection oConn = new SqlConnection(sConn);

   // Create a new DataAdapter using the Connection Object and SQL statement   SqlDataAdapter oDa = new SqlDataAdapter(sSQL, oConn);

   // Create a new DataSet Object to fill with Data   DataSet oDs = new DataSet();

   // Fill the DataSet with Data from the DataAdapter Object   oDa.Fill(oDs, "ewDataSet");   return oDs.Tables[0].DefaultView;  }  catch (SqlException oErr)  {   Session["dberrmsg"] = ewDataErrorMessage(oErr);   return null;  } } // End ewDataView

 //********************************* //  返回一个 DataView for Linking //*********************************

 public DataView ewDataViewLink(string sConn, string sTable/*表名*/,  string sLnkFld, string sDispFld,  string sDispFld2, string sFilterFld,  string sOrderBy/*排序列*/, string sOrderType/*排序规则*/,  bool bDistinct/*是否剔除重复值*/, string sFilter) {  string sSQL;  try  {

   // Construct SQL statement   sSQL = "SELECT";   if (bDistinct)   {    sSQL += " DISTINCT";   }   sSQL += " [" + sLnkFld + "], [" + sDispFld + "]";   if (sDispFld2 != "")   {    sSQL += ", [" + sDispFld2 + "]";   }   if (sFilterFld != "")   {    sSQL += ", [" + sFilterFld + "]";   }   sSQL += " FROM [" + sTable + "]";   if (sFilter != "")   {    sSQL += " WHERE " + sFilter;   }   if (sOrderBy != "")   {    sSQL += " ORDER BY [" + sOrderBy + "] " + sOrderType;   }

   // Create a new Connection Object using the Connection String   SqlConnection oConn = new SqlConnection(sConn);

   // Create a new DataAdapter using the Connection Object and SQL statement   SqlDataAdapter oDa = new SqlDataAdapter(sSQL, oConn);

   // Create a new DataSet Object to fill with Data   DataSet oDs = new DataSet();

   // Fill the DataSet with Data from the DataAdapter Object   oDa.Fill(oDs, "ewDataSet");

   // Create the TextField and ValueField Columns   oDs.Tables[0].Columns.Add("ewValueField",Type.GetTy