2008年4月9日

在 Windows Forms 列印報表

資料來源處:https://www.microsoft.com/taiwan/msdn/library/2003/May-2003-tw/printwinforms.htm

如何存取一個 Windows Form 在另一個 Windows Form 的成員藉由使用 Visual Basic . NET 或 Visual Basic 2005

資料來源處:http://support.microsoft.com/kb/841292/zh-tw

2008年4月7日

[ASP.Net]DataSet新增資料(DataRow)並透過xml格式儲存讀寫

[ASP.Net]DataSet新增資料(DataRow)並透過xml格式儲存讀寫




--------------------------------------------------------------------------------
try
{
//建立儲存選取之mailing List DataSet
DataSet ds = new DataSet();
ds.Tables.Add("CHECKED"); //新增CHECKED資料表至DATASET ds之中
ds.Tables["CHECKED"].Columns.Add("STU_ID"); //新增欄位STU_ID至DATASET ds之中
ds.Tables["CHECKED"].Columns.Add("STU_NAME");
ds.Tables["CHECKED"].Columns.Add("CMP_NAME");
ds.Tables["CHECKED"].Columns.Add("EMAIL");
for(int i = 0; i {
HtmlInputCheckBox app_no = (HtmlInputCheckBox)dgEmail.Items[i].FindControl("chkSTU_ID");

if(app_no.Checked)
{
System.Data.DataRow row = ds.Tables["CHECKED"].NewRow();

row["STU_ID"]=dgEmail.Items[i].Cells[6].Text; //由dgEmail這個DataGrid新增學生編號
row["STU_NAME"]=dgEmail.Items[i].Cells[0].Text;
row["CMP_NAME"]=dgEmail.Items[i].Cells[1].Text;
row["EMAIL"]=dgEmail.Items[i].Cells[4].Text;

ds.Tables["CHECKED"].Rows.Add(row);
}
}
//將建立之mailing List DataSet的資料寫入 mailList.xml 檔案
ds.WriteXml(Server.MapPath(Config.Document.Training_Education)+ "/mailList.xml",XmlWriteMode.WriteSchema);
ds.Dispose();
}
catch(Exception ex)
{
Response.Write(ex.Message);
}


--------------------------------------------------------------------------------


--------------------------------------------------------------------------------

DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath(Config.Document.Training_Education)+"/mailList.xml");

2008年4月5日

HOW TO:建立縮圖影像

資料來源處: http://msdn2.microsoft.com/zh-tw/library/ets0sayh(vs.80).aspx

HOW TO:建立縮圖影像
縮圖影像是影像的縮小版本。您可以藉由呼叫 Image 物件的 GetThumbnailImage 方法來建立縮圖影像。

下列範例會從 Compass.bmp 檔案建構 Image 物件。原始影像的寬度為 640 個像素,高度為 479 個像素。程式碼會建立寬度為 100 個像素,高度為 100 個像素的縮圖影像。
下圖顯示的是縮圖影像。

Dim image As New Bitmap("Compass.bmp")
Dim pThumbnail As Image = image.GetThumbnailImage(100, 100, Nothing, _
New IntPtr())
e.Graphics.DrawImage( _
pThumbnail, _
10, _
10, _
pThumbnail.Width, _
pThumbnail.Height)

2008年3月31日

How To Use Splitters Controls [ Splitters ]

範例1:


6. How To Use Splitters Controls [ Splitters ]
An Example:



1. Draw a panel on the form

2. Draw a textbox on the panel ( TextBox1.width is ( 1/2 Panel1.width ) )

3. Set TexBox1's Dock property to Left

4. Draw a splitter on the panel and set its Dock property to Left

5. Run Your Application

6. Now resize your TextBox1 by dragging the splitter


範例2:
An Explorer-Style Application
You are attempting to produce an interface in the format of the Windows Explorer, Outlook, and other applications. This interface will have a TreeView along one side of the form and a ListView on the other, and have the capability to move the dividing line between the two controls to resize them (see Figure 3.17).



Figure 3.17

The standard Explorer style of form layout.

This style of layout is easy to accomplish with the new features of Windows forms, but the specific order in which you add items to your form is important.

Starting with a blank form, add a TreeView control and set its Dock property to Left.
Add a Splitter control; it will automatically dock to the left and take its place along the right side of the TreeView.
Add a ListView control and set its Dock property to Fill.
That's it. The ListView will fill whatever space isn't being used by the TreeView and the Splitter will allow you to adjust the relative size of the two areas.

That is all of the sample resizing scenarios covered in this chapter, but that certainly is not the extent of layouts that can be created.

2008年3月29日

具名參回方式,存取資料庫

連接SQL.
connStr = "Server=(local); database=票據; uid=sa; pwd=;"
conn = New SqlConnection(connStr)
conn.Open()
updateCmd = "update 廠商 Set C_Co=@公司 ,C_LTD=@簡稱 Where C_No=@編號"
cmd = New SqlCommand(updateCmd, conn)
cmd.Parameters.Add(New SqlParameter("@編號", SqlDbType.Char))
cmd.Parameters.Add(New SqlParameter("@公司", SqlDbType.Char))
cmd.Parameters.Add(New SqlParameter("@簡稱", SqlDbType.Char))
cmd.Parameters("@編號").Value = txtC_No.Text
cmd.Parameters("@公司").Value = txtC_Co.Text
cmd.Parameters("@簡稱").Value = txtC_LTD.Text
cmd.ExecuteNonQuery()

連接Access.
connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=票據.mdb"
conn = New OleDbConnection(connStr)
conn.Open()
updateCmd = "update 廠商 Set C_Co=@公司 ,C_LTD=@簡稱 Where C_No=@編號"
cmd = New OleDbCommand(updateCmd, conn)
cmd.Parameters.Add(New OleDbParameter("@編號", OleDbType.Char))
cmd.Parameters.Add(New OleDbParameter("@公司", OleDbType.Char))
cmd.Parameters.Add(New OleDbParameter("@簡稱", OleDbType.Char))
cmd.Parameters("@編號").Value = txtC_No.Text
cmd.Parameters("@公司").Value = txtC_Co.Text
cmd.Parameters("@簡稱").Value = txtC_LTD.Text
cmd.ExecuteNonQuery()

結果 :
SQL 版,完全正常
Access版則會存成 ==> 公司(C_Co)會存到編號(C_No),簡稱(C_LTD)會存到公司(C_Co)的資料 !?
請教高手,何處錯了,謝謝指導~


以上問題已ok了 ~
在SQL語法中的順序是=>公司、簡稱、編號,所以我將具名參數的順序也修改成=>公司、簡稱、編號即ok了,如下:
connStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=票據.mdb"
conn = New OleDbConnection(connStr)
conn.Open()
updateCmd = "update 廠商 Set C_Co=@公司 ,C_LTD=@簡稱
Where C_No=@編號"
cmd = New OleDbCommand(updateCmd, conn)
cmd.Parameters.Add(New OleDbParameter("@公司",
OleDbType.Char))
cmd.Parameters.Add(New OleDbParameter("@簡稱",
OleDbType.Char))
cmd.Parameters.Add(New OleDbParameter("@編號",
OleDbType.Char))
cmd.Parameters("@公司").Value = txtC_Co.Text
cmd.Parameters("@簡稱").Value = txtC_LTD.Text
cmd.Parameters("@編號").Value = txtC_No.Text
cmd.ExecuteNonQuery()

#問題是在SQL server 2000怎沒順序問題 ? 好奇怪 @#$%

2008年3月27日

如何重新註冊 Windows 主從式架構在 WSUS

重新註冊 Windows 主從式架構在 WSUS

如果要重新登錄 Windows 主從式架構在 WSUS 檢閱下列指示:

1. 在 Windows 主從式架構 WSUS 中具有一個註冊問題執行 「 gpupdate / force 」 命令。

在 Windows 主從式架構 WSUS 中具有一個註冊問題 2. 執行 " wuauclt /detectnow 」 命令。


秘訣: 您可以使用 [ 事件檢視器來檢閱重新註冊

疑難排解工具

http://www.microsoft.com/technet/prodtechnol/sbs/2003/support/documentation/53979bbb-3099-44ac-98bc-097959ac8b5c.mspx?mfr=true

3. 在極少數情況下, 您可能會要執行: " wuauclt.exe /resetauthorization /detectnow 」 命令

Windows 主從式架構 WSUS 中具有一個註冊問題上的指令。


http://support.microsoft.com/kb/555974/zh-tw

2008年3月21日

類似輸入認證碼的那種功能.txt

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Response.ContentType = "image/png" '<== 你是 DOC 文件的話 image/png 可以改成 application/msword 或 application/octet-stream
Dim StockBitMap As Bitmap '<== 這是等一下準備要透過 MemoryStream 輸出的圖片
Dim memStream As New IO.MemoryStream

Dim RndCode As String = Request("RndCode") '<== 接收 RndCode 的值
StockBitMap = CImage.StringToBMP(Left(CEncrypt.EncryptString(RndCode)) '<== RndCode 會經過演算產生出不同的文字,再透過自訂的 CImage 類別產生一張圖片
StockBitMap.Save(memStream, System.Drawing.Imaging.ImageFormat.Png) '<== 將圖片存到 MemoryStream 內
memStream.WriteTo(Response.OutputStream) '<== 輸出Stream

StockBitMap.Dispose()
memStream.Close()
End Sub

2008年3月16日

How to adjust the column width in a datagrid??

爬文好久,總算找到處理方式了,
開發過程中,發現每次執行這個功能,都要手動調,
若沒有自動調整datagird的欄位寛度,使用者保証瘋掉~

以下是我自已整理出來旳sample code












ASP.Net IIS 註冊工具 -- aspnet_regiis.exe

ASP.Net IIS 註冊工具 -- aspnet_regiis.exe
ASP.NET 為一種動態網頁語言,必需安裝 .Netframework 元件才能使 IIS Web 具備有執行 ASP.net 程式能力。但因安裝順序錯誤,使得 ASP.NET 沒有註冊因而無法執行,造成用戶端 (Client) 在執行 ASP.NET 程式時,所有點選的程式不會執行,反而被當成一般文件下載。
因此正確安裝方式是必須先安裝 IIS 程式後,才加裝 .Netframework 元件。才不會造成 ASP.Net 沒有在 IIS 註冊,而無法執行的窘境。倘若您不小心安裝順序出現錯誤,也可利用 ASP.Net IIS 註冊工具 -- aspnet_regiis.exe 在 IIS 中註冊 ASP.Net 解決此一問題。作法:
• 找到 aspnet_regiis.exe 檔案的位置 , 可以對 windows 目錄作搜尋。 • 檔案所在的路徑會因為安裝的版本不同而異,下列路徑僅供參考: C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\aspnet_regiis.exe • 進入 dos 提示視窗模式,開始 a 執行 a cmd a 切換目錄到 .netframework 安裝目錄 ( 如作法 2 路徑 ) a 下 aspnet_regiis –i 指令,就會 重新註冊 ASP.Net 於 IIS 。 • 進入 dos 提示視窗模式,下 iisreset 指令重起 IIS 讓新的設定生效。

http://msdn2.microsoft.com/zh-tw/library/k6h9cz8h(VS.80).aspx