Time of Update: 2018-12-06
(1)在SQL Server中建立如下的預存程序:set ANSI_NULLS ONset QUOTED_IDENTIFIER ONGOCREATE PROCEDURE [dbo].[GetNameById] @studentid varchar(8), @studentname nvarchar(50) OUTPUTASBEGIN SELECT @studentname=studentname FROM student WHERE studentid=@studentid if
Time of Update: 2018-12-06
C#從3.0開始支援匿名方法及Lambda運算式。1 匿名方法 AddDelegate del = delegate(int i, int j) { return i + j; }; Console.WriteLine(del(5, 6));使用匿名方法,要注意其文法特性。2 Lambda運算式可以使用Lambda運算式進一步簡化上面的代碼: AddDelegate d = (i, j) => {return i + j; }; Console.WriteLine(d(5, 6))
Time of Update: 2018-12-06
(1)拼接產生SQL語句: string sql = "insert into czyb(yhm,mm,qx) values('" + txtName.Text + "','" + txtPassword.Text + "','" + cmbPriority.Text + "')"; OleDbCommand cmd = new OleDbCommand(sql, conn);
Time of Update: 2018-12-06
讀取n個文字檔,把檔案內容合并到一個文字檔中。主要用了FileStream的ReadByte和WriteByte方法:class FileCombine{ public void CombineFile(String[] infileName,String outfileName) { int b; int n=infileName.Length; FileStream[] fileIn=new
Time of Update: 2018-12-06
為了方便開發,.Net類庫預定好了幾個泛型委派。1 Func系列委託 Func系列委託的定義: public delegate TResult Func<TResult>(); public delegate TResult Func<T,TResult>(T arg); public delegate TResult Func<T1,T2,TResult>(T1 arg1,T2 arg2); public
Time of Update: 2018-12-06
string StrSql = "exec proc_PriceReport '" + dgvOrderList.Rows[e.RowIndex].Cells[1].Value.ToString() + "'"; dt = DbHelper.DbHelperSQL.DataQuery(StrSql).Tables[0]; DataGridViewButtonColumn btnSave = new
Time of Update: 2018-12-06
1,水晶報表從資料庫中讀取的資料,當欄位內容比較長時,很影響美觀,需要設定它為自動換行來顯示。2.開啟欄位的“設定對象格式”屬性,將其“公用”標籤下的“可以擴大屬性選上,*該設定可以使邊框自適應寬度3.開啟節專家,將詳細資料中的“延伸到後續節”選中,如果有多個節點的話可以把多個節點全部選中;4.將報表中線條控制項的“設定對象格式”中“列印時擴充到節的底部”屬性勾選上,這樣線條也會根據每行的資料高度自動向下移動。 1,建立dataset.xsd
Time of Update: 2018-12-06
1、C#調用JavaScript(1)準備好JavaScript函數 <script type="text/javascript"> function say() { alert("CSharp調用js,調用成功!"); } </script>(2)頁面代碼<asp:Button ID="Button1" runat="server" Text=
Time of Update: 2018-12-06
如果把照片直接儲存在SQL Server資料庫中,微軟推薦用varbinary(MAX)欄位。下面的代碼示範了用C#操作varbinary(MAX)欄位的基本方法。1、新增記錄 private void btnBrowse_Click(object sender, EventArgs e)//瀏覽照片 { OpenFileDialog dlg = new OpenFileDialog(); dlg.Filter =
Time of Update: 2018-12-06
按照網上的方法,先添加"Microsoft Multimedia Control 6.0",再添加"Shockwave Flash Object",可是還是出現"未能匯入activex 控制項"的錯誤,最後發現原來是沒有把"Microsoft Multimedia Control 6.0"拉到FORM中的原因,拉過去一下就好了.按照以下步驟應該能夠成功:01.VS2005工具箱中“選擇項”-> “COM”中選擇“Microsoft Multimedia Control 6.0”
Time of Update: 2018-12-06
由於SSOAxCtrlForPTLogin.SSOForPTLogin2已經做了一些限制,所以已經無法直接引用到C#中使用了。 沒有辦法,只能藉助webbrowser了!function getqqlist(){for (var ii=0 ;ii<pt.list.length ;ii++ ){ var F=pt.list[ii]; var B = $.bom.query("u1"); var A = $.bom.query("ptredirect");
Time of Update: 2018-12-06
《C#資料庫應用程式開發技術與案例教程》一書是本人認真寫作完成的,沒有粗製濫造,沒有偷懶,沒有簡單拼湊,希望初學者能通過本書的學習,真正掌握基於ADO.NET的資料庫編程技術,領會物件導向編程思想,邁入軟體開發的大門。本書的詳細介紹,請參看:http://www.cnblogs.com/zhouhb/archive/2012/08/16/2643078.html如果大家在使用本書的過程中發現問題,請及時聯絡我。謝謝!目前發現的問題有:(1)第36頁:表5-2 按鈕屬性設定,實際應為:表5-2
Time of Update: 2018-12-06
索引器是一種特殊的類成員,它能夠讓對象以類似數組的方式來存取,使程式看起來更為直觀,更容易編寫。 1、索引器的定義C#中的類成員可以是任意類型,包括數組和集合。當一個類包含了數組和集合成員時,索引器將大大簡化對數組或集合成員的存取操作。定義索引器的方式與定義屬性有些類似,其一般形式如下:[修飾符] 資料類型 this[索引類型 index]{ get{//獲得屬性的代碼} set{ //
Time of Update: 2018-12-06
//方案— 優點:僅使用C標準庫;缺點:只能精確到秒級 #include <time.h> #include <stdio.h> int main( void ) { time_t t = time(0); char tmp[64]; strftime( tmp, sizeof(tmp), "%Y/%m/%d %X %A 本年第%j天 %z",localtime(&t) ); puts( tmp ); return 0; } size_t
Time of Update: 2018-12-06
C++中的new其實是一個很糊弄人的術語,它有兩種不同的含義,new運算子(new operator)和new函數(operator new),值得記錄一下。一 new運算子最常用的是作為運算子的new,比如:string *str = new string(“test new”);作為運算子,new和sizeof一樣,是C++內建的,你不能對它做任何的改變,除了使用它。new會在堆上分配一塊記憶體,並會自動調用類的建構函式。二
Time of Update: 2018-12-06
一次性插入上萬條資料的寫法1.[csharp] view
Time of Update: 2018-12-06
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->using System;using System.Runtime.InteropServices;using System.Threading;class TestClass{ static void Main(string[] args) { new TestClass()
Time of Update: 2018-12-06
1.首先引入System.Runtime.InteropServices using System.Runtime.InteropServices; 2.在類內部聲明兩個API函數,它們的位置和類的成員變數等同.[System.Runtime.InteropServices.DllImport("user32.dll")] //申明API函數 public static extern bool RegisterHotKey( IntPtr
Time of Update: 2018-12-06
原文出處: http://www.c-sharpcorner.com/UploadFile/rmcochran/csharp_memory01122006130034PM/csharp_memory.aspx 儘管在.NET framework下我們並不需要擔心記憶體管理和記憶體回收(Garbage
Time of Update: 2018-12-06
一.類與結構的樣本比較: 結構樣本: public struct Person { string Name; int height; int weight public bool overWeight() { //implement something } } 類樣本: public class TestTime { int hours; int minutes;