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

2008年3月13日

[筆記]Blogger Backup ---Backup Utility Tutorial

目前 Google 尚未推出 Blogger 的備份服務,不過已經有人開發出好用的備份工具:Blogger Backup。
Blogger Backup 主要的目的就是要簡化將 Blogger 上面的文章備份到本地端硬碟的工具軟體,它能同時支援多個 blog。你隨時都能將 Blogger 上任何一段時間中的文章備份到本地端,
(是利用 GData C# 程式庫,遊走在不同的時間點,成為 Atom/XML 檔。 )

● 注意事項:Blogger Backup 是利用 Public Feed(網站提供)來備份你的文章。
如果 [網站提供] 沒有開放,那麼這套軟體將無法替你備份。
另外 [網站提供] 裡面的設定如果都是「簡短(Summary)」那麼只有文章的簡短內容會備份。
要備份完整文章,請在 [網站提供] 中將相關欄位設定成 [完整]。
如果你的 feeds 是透過 FeedBurner 重新導向,而且你將「flare(http://www.feedburner.com/fb/a/publishers/feedflare)」開啟的話(換言之,「email this」這些由 FeedBurner 加到你張貼文章下的功能),那麼這些 flare 也都會一並備份。(FYI:作者目前已經在撰寫新的選項,可以將 flare 排除掉。)

以下是使用完後,我自已作的筆記,
http://lab.blogdns.com/DOC/bloggerbackup.htm

2008年3月10日

[筆記]SQL Server 「逾時過期」的處理方式

SQL Server 「逾時過期」的處理方式
基本上 SQL Server 只要在處理大量資料的指令,如 INSERT INTO A SELECT * FROM B 在資料量很大的時候,很容易發生 Timeout ,也就是常見的「逾期過時」錯誤。

SQL Server 本機用 Enterprise Manager 執行的話還好處理,只要更改設定值就好了。(工具->選項->進階,加大逾時秒數)。

但是絕大部份都是在 Remote 下 SQL Command ,只要量稍大,這種「逾期過時」出現的機率也隨之增加。

解決的方式最好是加大 SQL Server Remote Command 的 Timeout 時間,只要在 SQL Queryer 裡面下:

USE master
GO
EXEC sp_configure 'remote query timeout', 6000
GO
RECONFIGURE
GO

6000 代表的是秒數,也就是 6000 秒(SQL Server預設是 600 秒,)。

另一種就是用外部程式來處理,但是可能還是會受限於 SQL Server 的限制,尤其 ADODB 在這部份還有嚴重的Bug,詳見:

PRB: CommandTimeout Does Not Inherit From Connection Timeout
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q195489


程式設定 CommandTimeout 處理的範例:

Dim conn As New ADODB.Connection
conn.Open(ConnStr)
conn.CommandTimeout = 600 '秒
conn.Execute("INSERT INTO A SELECT * FROM B")
conn.Close()
conn = Nothing

需注意的是在 ADODB 2.6 以前,CommandTimeout 不可以設為 0 (無限制時間),非不得以要使用的話,必須使用 ADODB.Command,詳見:

FIX:使用 Connection 物件時的 CommandTimout 屬性問題
http://support.microsoft.com/default.aspx?scid=kb;zh-tw;175264

This virtual machine appears to be in use.

This virtual machine appears to be in use.

執行環境:VMWARE 6

當執行VMWARE GUEST OS時,
若出現以下錯誤訊息:

Could not open virtual machine: D:\GuestOS\QP_20070619\Windows Server 2003 Standard Edition.vmx. This virtual machine appears to be in use.

Configuration file: D:\GuestOS\QP_20070619\Windows Server 2003 Standard Edition.vmx

解決方法:刪除GUEST OS資料夾底下的.lck檔案

參考:http://www.vmware.com/community/thread.jspa?messageID=673176