Program
An existing database (SQL) table that quickly generates a tool for the corresponding stored procedure. SQLPilot.exe
SQLPilot.exe This program is written by a friend of CCF, please refer to http://bbs.et8.net/bbs/showthread.php?t=534183
Second, the existing database table, quickly generate lists, basic queries, advanced queries, insert new rows, delete, edit asp.net page tools asp.net Maker
http://www.hkvstore.com/aspnetmaker/
1. Database Operation class
The following is the C # code:
Header file:
Using system;using system.web.ui;using system.globalization;using system.data;using system.data.sqlclient;namespace Ns_db{public class c_db:usercontrol{
Returns the database connection string//********************************
public string Ewconnstr () {return "password=******; Persist Security info=true; User id=sa;initial catalog=******;D ata source=
(local) "; }//End EWCONNSTR
Returns a DataView based on 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
Returns a DataView for linking//*********************************
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"); Return Convert.ToInt32 (Ods.tables[0]. Rows[0][0]); catch (SqlException oerr) {session["dberrmsg"] = Ewdataerrormessage (Oerr); return 0; }//End Ewrecordcount
Returns 1-page DataView according to Connection String & SQL//*** ********************************************************
Public DataView ewdataviewpage (string sconn, string ssql, int icurrentrec, int ipagesize) {try {
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, Icurrentrec, Ipagesize, "Ewdataset"); Return ods.tables[0]. DefaultView; catch (SqlException oerr) {session["dberrmsg"] = Ewdataerrormessage (Oerr); return null; }//End Ewdataviewpage
Return a DataReader based on Connection & SQL//************* ************************************
Public SqlDataReader Ewdatareader (SqlConnection oconn, string sSQL) {try {
Create a DataReader Object SqlDataReader oDr;
Create a new Command Object using the Connection and SQL statement SqlCommand ocmd = new SqlCommand (sSQL, oconn);
Execute the SQL statement against the Command to get the DataReader oDr = Ocmd.executereader (); return oDr; catch (SqlException oerr) {session["dberrmsg"] = Ewdataerrormessage (Oerr); return null; }//End Ewdatareader
Return error message based on Error Object//********************** ************************
public string Ewuploadfilename (string sfilename) {string soutfilename;
Amend your logic here soutfilename = sFileName;
Return computed output file name return soutfilename; }//End Ewuploadfilename
Return formatted number similar to VB formatnumber//-incl Udeleadingdigit is not supported//******************************************************
public string Ewformatnumber (object oNo, int idecplace, int iuseparen, int igroupdigits) {NumberFormatInfo Onfi = (numbe Rformatinfo) NumberFormatInfo.CurrentInfo.Clone (); Onfi.numberdecimaldigits = Idecplace; Numdigitsafterdecimal
Includeleadingdigit:not used if (Iuseparen = = 1)//useparensfornegativenumbers:true {Onfi.numbernegativepatter n = 0; else if (Iuseparen = 0)//useparensfornegativenumbers:false {onfi.numbernegativepattern = 1; } if (igroupdigits = = 1)//groupdigits:true {onfi.numbergroupseparator = ","; else if (igroupdigits = 0)//groupdigits:false {onfi.numbergroupseparator = ""; }
//Cast for different data types if (ONo are short)//short {return ((short) oNo). ToString ("n", ONFI); } else if (ONo is ushort)//ushort {return ((ushort) oNo). ToString ("n", ONFI); } else if (oNo is int)//int {return ((int) oNo). ToString ("n", ONFI); } else if (ONo is uint)//uint {return ((UINT) oNo). ToString ("n", ONFI); } else if (ONo is long)//long {return ((Long) oNo). ToString ("n", ONFI); } else if (ONo is ulong)//ulong {return ((ULONG) oNo). ToString ("n", ONFI); } else if (ONo is float)//float {return ((float) oNo). ToString ("n", ONFI); } else if (ONo is double)//double {return (double) oNo). ToString ("n", ONFI); } else if (ONo is decimal)//decimal {return ((decimal) oNo). ToString ("n", ONFI); } else {return ((decimal) oNo). ToString ("n", Onfi); } }
Return formatted Currency similar to VB formatcurrency -IncludeLeadingDigit is not supported//**********************************************************
public string Ewformatcurrency (object oNo, int idecplace, int iuseparen, int igroupdigits) {NumberFormatInfo Onfi = (Num Berformatinfo) NumberFormatInfo.CurrentInfo.Clone (); Onfi.currencydecimaldigits = Idecplace; Numdigitsafterdecimal
Includeleadingdigit:not used if (Iuseparen = = 1)//useparensfornegativenumbers:true {Onfi.currencynegativepatt Ern = 0; else if (Iuseparen = 0)//useparensfornegativenumbers:false {onfi.currencynegativepattern = 1; } if (igroupdigits = = 1)//groupdigits:true {onfi.currencygroupseparator = ","; else if (igroupdigits = 0)//groupdigits:false {onfi.currencygroupseparator = ""; }
//Cast for different data types if (ONo are short)//short {return ((short) oNo). ToString ("C", ONFI); } else if (ONo is ushort)//ushort {return ((ushort) oNo). ToString ("C", ONFI); } else if (oNo is int)//int {return ((int) oNo). ToString ("C", ONFI); } else if (ONo is uint)//uint {return ((UINT) oNo). ToString ("C", ONFI); } else if (ONo is long)//long {return ((Long) oNo). ToString ("C", ONFI); } else if (ONo is ulong)//ulong {return ((ULONG) oNo). ToString ("C", ONFI); } else if (ONo is float)//float {return ((float) oNo). ToString ("C", ONFI); } else if (ONo is double)//double {return (double) oNo). ToString ("C", ONFI); } else if (ONo is decimal)//decimal {return ((decimal) oNo). ToString ("C", ONFI); } else {return ((decimal) oNo). ToString ("C", Onfi); } }
Return formatted Percent similar to VB formatpercent//- IncludeLeadingDigit is not supported//********************************************************
public string Ewformatpercent (object oNo, int idecplace, int iuseparen, int igroupdigits) {NumberFormatInfo Onfi = (Numb Erformatinfo) NumberFormatInfo.CurrentInfo.Clone (); Onfi.currencydecimaldigits = Idecplace; Numdigitsafterdecimal
Includeleadingdigit:not used if (Iuseparen = = 1)//useparensfornegativenumbers:true {Onfi.currencynegativepatt Ern = 0; else if (Iuseparen = 0)//useparensfornegativenumbers:false {onfi.currencynegativepattern = 1; } if (igroupdigits = = 1)//groupdigits:true {onfi.currencygroupseparator = ","; else if (igroupdigits = 0)//groupdigits:false {onfi.currencygroupseparator = ""; }
//Cast for different data types if (ONo are short)//short {return ((short) oNo). ToString ("P", ONFI); } else if (ONo is ushort)//ushort {return ((ushort) oNo). ToString ("P", ONFI); } else if (oNo is int)//int {return ((int) oNo). ToString ("P", ONFI); } else if (ONo is uint)//uint {return ((UINT) oNo). ToString ("P", ONFI); } else if (ONo is long)//long {return ((Long) oNo). ToString ("P", ONFI); } else if (ONo is ulong)//ulong {return ((ULONG) oNo). ToString ("P", ONFI); } else if (ONo is float)//float {return ((float) oNo). ToString ("P", ONFI); } else if (ONo is double)//double {return (double) oNo). ToString ("P", ONFI); } else if (ONo is decimal)//decimal {return ((decimal) oNo). ToString ("P", ONFI); } else {return ((decimal) oNo). ToString ("P", onfi); }&NBSP}}//End Class}//End NameSpace
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.