TREEVIEW只输入表名,父ID,节点ID,节点名就得到树型结构之十(转)
/// <summary> /// Execute a SqlCommand (that returns a resultset and takes no parameters) against the provided SqlConnection. /// </summary> /// <remarks> /// e.g.: /// SqlDataReader dr = ExecuteReader(conn, CommandType.StoredProcedure, "GetOrders"); /// </remarks> /// <param name="connection">A valid SqlConnection</param> /// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
TREEVIEW只输入表名,父ID,节点ID,节点名就得到树型结构之八(转)
/// <summary> /// This enum is used to indicate whether the connection was provided by the caller, or created by SqlHelper, so that /// we can set the appropriate CommandBehavior when calling ExecuteReader() /// </summary> private enum SqlConnectionOwnership { /// <summary>Connection is owned and managed by SqlHelper</summary> Internal, /// <summary>Connection is owned and managed by the caller</summary> External } /// <summary> /// Cre
TREEVIEW只输入表名,父ID,节点ID,节点名就得到树型结构之九(转)
/// <summary> /// Execute a SqlCommand (that returns a resultset and takes no parameters) against the database specified in /// the connection string. /// </summary> /// <remarks> /// e.g.: /// SqlDataReader dr = ExecuteReader(connString, CommandType.StoredProcedure, "GetOrders"); /// </remarks> /// <param name="connectionString">A valid connection string for a SqlConnection</param> /// <param name="commandType"&g
TREEVIEW只输入表名,父ID,节点ID,节点名就得到树型结构之七(转)
/// <summary> /// Execute a SqlCommand (that returns a resultset) against the specified SqlTransaction /// using the provided parameters. /// </summary> /// <remarks> /// e.g.: /// DataSet ds = ExecuteDataset(trans, CommandType.StoredProcedure, "GetOrders", new SqlParameter("@prodid", 24)); /// </remarks> /// <param name="transaction">A valid SqlTransaction</param> /// <param name="commandType">The Comm
TREEVIEW只输入表名,父ID,节点ID,节点名就得到树型结构之六(转)
/// <summary> /// Execute a stored procedure via a SqlCommand (that returns a resultset) against the specified SqlConnection /// using the provided parameter values. This method will query the database to discover the parameters for the /// stored procedure (the first time each stored procedure is called), and assign the values based on parameter order. /// </summary> /// <remarks> /// This method provides no access to output parameters or the stored procedure's return
TREEVIEW只输入表名,父ID,节点ID,节点名就得到树型结构之四(转)
/// <summary> /// Execute a SqlCommand (that returns no resultset and takes no parameters) against the provided SqlConnection. /// </summary> /// <remarks> /// e.g.: /// int result = ExecuteNonQuery(conn, CommandType.StoredProcedure, "PublishOrders"); /// </remarks> /// <param name="connection">A valid SqlConnection</param> /// <param name="commandType">The CommandType (stored procedure, text, etc.)</param>
TREEVIEW只输入表名,父ID,节点ID,节点名就得到树型结构之五(转)
/// <summary> /// Execute a SqlCommand (that returns no resultset and takes no parameters) against the provided SqlTransaction. /// </summary> /// <remarks> /// e.g.: /// int result = ExecuteNonQuery(trans, CommandType.StoredProcedure, "PublishOrders"); /// </remarks> /// <param name="transaction">A valid SqlTransaction</param> /// <param name="commandType">The CommandType (stored procedure, text, etc.)</param
TREEVIEW只输入表名,父ID,节点ID,节点名就得到树型结构之三(转)
/// <summary> /// This method opens (if necessary) and assigns a connection, transaction, command type and parameters /// to the provided command /// </summary> /// <param name="command">The SqlCommand to be prepared</param> /// <param name="connection">A valid SqlConnection, on which to execute this command</param> /// <param name="transaction">A valid SqlTransaction, or 'null'</param> /// <param name="
TREEVIEW只输入表名,父ID,节点ID,节点名就得到树型结构之二(转)
-----------------------------------数据访问层----------------------------//===============================================================================//数据访问层中最基本的应用程序块(来自微软Microsoft Application Blocks for .NET)//提供所有有关操作SQL SERVER操作数据库的功能//乔高峰 2005-04-27//===============================================================================using System;using System.Data;using System.Xml;using System.Data.SqlClient;using System.Collections;using System.Config
TREEVIEW只输入表名,父ID,节点ID,节点名就得到树型结构之一(转)
调用时如下: /// <param name="newTreeView">树型控件名称</param> /// <param name="TreeViewName">一层的功能名称</param> /// <param name="TableName">数据库中的表名</param> /// <param name="ParentNameField">父节点的字段名</param> /// <param name="CurrentNameField">节点的字段名</param> /// <param name="CurrentDataField">节点的数据</
c#.net常用函数和方法集之八(转)
2、Int32.Parse(变量) Int32.Parse("常量") 字符型转换 转为32位数字型 3、 变量.ToString() 字符型转换 转为字符串 12345.ToString("n"); //生成 12,345.00 12345.ToString("C"); //生成 ¥12,345.00 12345.ToString("e"); //生成 1.234500e+004 12345.ToString("f4"); //生成 12345.0000 12345.ToString("x"); //生成 3039 (16进制) 12345.ToString("p"); //生成 1,234,500.00% 4、变量.Length 数字型 取字串长度: 如: string str="中国"; int Len
c#.net常用函数和方法集之七(转)
1、DateTime 数字型 System.DateTime currentTime=new System.DateTime(); 1.1 取当前年月日时分秒 currentTime=System.DateTime.Now; 1.2 取当前年 int 年=currentTime.Year; 1.3 取当前月 int 月=currentTime.Month; 1.4 取当前日 int 日=currentTime.Day; 1.5 取当前时 int 时=currentTime.Hour; 1.6 取当前分 int 分=currentTime.Minute; 1.7 取当前秒 int 秒=currentTime.Second; 1.8 取当前毫秒 int 毫秒=currentTime.Millisecond; (变量可用中文) 1.9 取中文日期显示——年月日时分 string strY=currentTime.ToString("f&qu
c#.net常用函数和方法集之六(转)
27、Remove() 从指定位置开始删除指定数的字符 字串对比一般都用: if(str1==str2){ } , 但还有别的方法: 1、 string str1; str2 //语法: str1.EndsWith(str2); __检测字串str1是否以字串str2结尾,返回布尔值.如: if(str1.EndsWith(str2)){ Response.Write("字串str1是以"+str2+"结束的"); } 2、 //语法:str1.Equals(str2); __检测字串str1是否与字串str2相等,返回布尔值,用法同上. 3、 //语法 Equals(str1,str2); __检测字串str1是否与字串str2相等,返回布尔值,用法同上. IndexOf() 查找字串中指定字符或字串首次出现
c#.net常用函数和方法集之四(转)
19、(char)代码 把数字转为字符,查代码代表的字符。 如: Response.Write((char)22269); //返回“国”字。 20、 Trim() 清除字串前后空格 21 、字串变量.Replace("子字串","替换为") 字串替换 如: string str="中国"; str=str.Replace("国","央"); //将国字换为央字 Response.Write(str); //输出结果为“中央” 再如:(这个非常实用) string str="这是<script>脚本"; str=str.Replace("<","<font><</font>"); //将左尖括号
c#.net常用函数和方法集之五(转)
23、字串对比一般都用: if(str1==str2){ } , 但还有别的方法: (1)、 string str1; str2 //语法: str1.EndsWith(str2); __检测字串str1是否以字串str2结尾,返回布尔值.如: if(str1.EndsWith(str2)){ Response.Write("字串str1是以"+str2+"结束的"); } (2)、 //语法:str1.Equals(str2); __检测字串str1是否与字串str2相等,返回布尔值,用法同上. (3)、 //语法 Equals(str1,str2); __检测字串str1是否与字串str2相等,返回布尔值,用法同上. 24、IndexOf() 、LastIndexOf() 查找字串中指定字符或字串首次(最后一次)出现的
c#.net常用函数和方法集之二(转)
4、变量.Length 数字型 取字串长度: 如: string str="中国"; int Len = str.Length ; //Len是自定义变量, str是求测的字串的变量名 5、System.Text.Encoding.Default.GetBytes(变量) 字码转换 转为比特码 如:byte[] bytStr = System.Text.Encoding.Default.GetBytes(str); 然后可得到比特长度: len = bytStr.Length; 6、System.Text.StringBuilder("") 字符串相加,(+号是不是也一样?) 如:System.Text.StringBuilder sb = new System.Text.StringBuilder(""); sb.Append("中华"); sb.Ap
C#调用父类的父类的方法(转)
override一个C#函数时,如果想调用这个函数在父类的父类中相应的方法,可以将override关键字变成new,调用时将Object转义成父类的父类class A{ public virtual void Func() { Console.WriteLine("A"); }}class B:A{ public new void Func() { Console.WriteLine("B"); }}class C:B{ public void Func() { A a = this as C; a.Func(); }}[@more@]
c#.net常用函数和方法集之一(转)
1、DateTime 数字型 System.DateTime currentTime=new System.DateTime(); 1.1 取当前年月日时分秒 currentTime=System.DateTime.Now; 1.2 取当前年 int 年=currentTime.Year; 1.3 取当前月 int 月=currentTime.Month; 1.4 取当前日 int 日=currentTime.Day; 1.5 取当前时 int 时=currentTime.Hour; 1.6 取当前分 int 分=currentTime.Minute; 1.7 取当前秒 int 秒=currentTime.Second; 1.8 取当前毫秒 int 毫秒=currentTime.Millisecond; (变量可用中文) 2、Int32.Parse(变量) Int32.Parse("常量") 字符型转换 转为32位数字型
利用C#线程机制实现应用程序的单实例运行(转)
只要你的程序中Main入口是如下的,则你的程序在运行时,在一个时刻只能有一个程序实例,比如Winamp就是这种,当它在运行时,再又击这个程序,是不会再运行一个实例的.代码很简单[STAThread] static void Main(string[] args) { bool isExist; System.Threading.Mutex mutex=new System.Threading.Mutex(true,"myApp",out isExist); //这里的myApp是程序的标识,建议换成你的程序的物理路径,这样的话如果在一个操作系统中这个标志不会和其它程序冲突 if(isExist)Environment.Exit(1);
C#中使用反射显示程序集的所有类型和属性(转)
/// <summary> /// /// loads a *.dll file from txtMethods and invokes all methods int it. /// lists all types in the assembly /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnList_Click(object sender, System.EventArgs e) { string fileName=labelFile.Text.Trim(); string result=""; txtMethods.Text=""; txtTypes.Text=""; if(File.Exists(fileName)