2011年6月30日 星期四

ASP.Net 設定轉址

1.可在Page_Load事件加入:
response.redirect (~/xxx.aspx")
2.可用文字檔新增一個xxx.asp的檔案,內容為:
<% response.redirect ("http://www.google.com.tw") %>

[轉貼] .Net 如何知道遠端電腦的剩餘磁碟空間

來源:http://www.blueshop.com.tw/board/show.asp?subcde=BRD200607311444336E3&fumcde=FUM20050124191756KKC&odr=cdt&odrtyp=0



Imports System.Runtime.InteropServices

    <DllImport("Kernel32")> _
    Public Shared Function GetDiskFreeSpaceEx(ByVal lpDirectoryName As String, ByRef lpFreeBytesAvailable As UInt64, ByRef lpTotalNumberOfBytes As UInt64, ByRef lpTotalNumberOfFreeBytes As UInt64) As <MarshalAs(UnmanagedType.Bool)> Boolean
    End Function

    Private Function GetFreeDiskSpace(ByVal driveLetter As String) As UInt64

        Dim freespace As UInt64
        If GetDiskFreeSpaceEx(driveLetter, Nothing, Nothing, freespace) Then
            Return freespace
        Else
            Return New UInt64
        End If

    End Function

Dim dirName As String = "C:\"
        MessageBox.Show(String.Format("{0} 目前尚有 {1} 個位元組的可用空間", dirName, GetFreeDiskSpace(dirName)))
----------------------------------------------------------------------------
 Dim cdrive As System.IO.DriveInfo
    cdrive = My.Computer.FileSystem.GetDriveInfo("C:\")
    MsgBox("Total free space: " & CStr(cdrive.TotalFreeSpace))

[轉貼] VB6.0 如何知道遠端電腦的剩餘磁碟空間

來源:http://www.programmer-club.com.tw/ShowSameTitleN/vb/32456.html

Private Declare Function GetDiskFreeSpace Lib "kernel32" _
   Alias "GetDiskFreeSpaceA" (ByVal lpRootPathName As String, _
   lpSectorsPerCluster As Long, lpBytesPerSector As Long, _
   lpNumberOfFreeClusters As Long, lpTtoalNumberOfClusters As Long) As Long

Public Function GetFreeHDSpace(ByVal Path As String) As Variant
Dim Status As Long
Dim dbV As Double
Dim SecPerClust As Long
Dim BytePerSec As Long, FreeClust As Long, totClust As Long
Status = GetDiskFreeSpace(Path, SecPerClust, BytePerSec, FreeClust, totClust)
dbV = SecPerClust * BytePerSec
dbV = dbV * FreeClust
GetFreeHDSpace= dbV
End Function

Private Sub Command1_Click()
MsgBox GetFreeSpace("\\x.x.x.x\c$")
End Sub

用遠端桌面連Windows XP時的關機方式

1.30秒後重開機:shutdown - r -t 30


2.30秒後關機:shutdown - s -t 30


也可以做成批次檔放在桌面上

製作可以安裝 Windows 7 / Windows Server 2008 R2 的USB隨身碟

1.在 Windows 7 或 Windows Server 2008 R2 的環境下
   用系統管理員的身份執行『命令提示字元』
2.diskpart
3.list disk:會列出該台電腦所有的實體磁碟
4.檢查結果,並紀錄隨身碟的磁碟編號
5.select disk n:n是隨身碟的磁碟編號
6.clean:清理隨身碟,不會再有任何分割區
7.create partition primary:會在隨身碟建立主分割區
8.select partition 1:選取隨身碟的唯一分割區
9.active:將所選取的分割區設為「使用中」
10.format fs=fat32 quick:將隨身碟格式化成FAT32
11.assign:將磁碟代號指定給隨身碟的分割區
12.exit:結束命令提示字元
13.將Windows 7或Windows Server 2008 R2 安裝光碟的內容全部複製到USB裡

安裝MS SQL Server 時發生[效能計數器登錄區一致性]的錯誤

我遇過幾次,有2種方式可以試試看,都不行的話,只好重裝了....

1.檢查該台電腦的地區語言選項是否與SQL SERVER 安裝版本一致

2.修改登錄編輯器
(1)執行 regedit
(2)HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Perflib
(3)進入004,檢查counter的值(就拉到最下面看最後一組數字)
(4)進入009,檢查counter的值 (同上)
(5)比較誰的數字比較大,記錄下來
(6)回到上一層的Perflib然後編輯Last Counter的值,將該數字填入(記得要選10進位)
(7)關機重開重新安裝SQL SERVER

讓TeamViewer只能接受區網內的連線遙控

General --> Incoming LAN connections --> 選擇 accept

[轉貼] VB6.0和VB.Net 函數對照表

在我從 VB6 開始轉到 .Net 時,這篇文章真的幫了我很大的忙~~
感謝 Louis瑋 先生
來源網址: http://blog.yam.com/ftplouis (Louis瑋的Blog)


VB6.0和VB.Net的對照表
VB6.0VB.NET
AddItem Object名.AddItemObject名.Items.AddListBox1.Items.AddComboBox1.Items.Add
Abs 函數System.Math.Abs 方法
API 函數關係Microsoft Win32和Microsoft .NET Framework API的對應
App.Path等1. System.Reflection.Assembly.GetExecutingAssembly.Location
2. Application.StartupPath
3. Application.ExecutablePath
4. System.AppDomain.CurrentDomain.BaseDirectory
App.PrevInstanceProcess.GetProcessesByName(pn).GetUpperBound(0) > 0
As Any 關鍵詞Visual Basic .NET 不提供支援。 參考方法(SendMessage)
AscB 函數Microsoft.VisualBasic.Strings.Asc 函數
Atn 函數System.Math.Atan 方法
AutoRedraw 屬性沒有相同項目。
BeepMicrosoft.VisualBasic.Beep()
Caption 屬性Text 屬性
CBool 函數CBool 函數
CByte 函數CByte 函數
CDate 函數CDate 函數
CDbl 函數CDbl 函數
CDec 函數CDec 函數
ChDir 語句Microsoft.VisualBasic.FileSystem.ChDir 函數
System.IO.Directory.SetCurrentDirectory 方法
ChDrive 語句Microsoft.VisualBasic.FileSystem.ChDrive 函數
Chr$ 函數、ChrB 函數Microsoft.VisualBasic.Strings.Chr 函數
CInt 函數CInt 函數
Circle 方法System.Drawing.Graphics.DrawEllipse 方法
CLong 函數CLong 函數
Close 語句Microsoft.VisualBasic.FileSystem.FileClose 函數
System.IO.StreamReader.Close 方法
Clipboard 對象System.Windows.Forms.Clipboard 命名空間
ClipControls 屬性沒有相同項目。
Cls 方法System.Drawing.Graphics.Clear 方法
Color QBColor
vbBlack RGB()
System.Drawing.Color.Black
CommandSystem.Environment.GetCommandLineArgs
Combo1.AddItemComboBox1.Items.Add
Cos 函數System.Math.Cos 方法
CSng 函數CSng 函數
CStr 函數CStr 函數
CurDir 函數System.IO.Directory.GetCurrentDirectory() 方法
Currency 類型Decimal 類型
CurrentX 屬性各種圖形相關方法的 x 參數。比如、DrawRectangle(pen, x, y, width, height)
CurrentY 屬性各種圖形相關方法的 y 參數。比如、DrawRectangle(pen, x, y, width, height)
Date 函數、Date 語句System.DateTime.Now System.DateTime.Today.ToString
Date$ 函數Microsoft.VisualBasic.DateAndTime.DateString
DateAdd 函數System.DateTime.AddYears 方法 AddMonths AddDays
DateDiff 函數Microsoft.VisualBasic.DateDiff 函數
DateValue 函數System.DateTime.Parse 方法 CDate 函數
DatePart 函數Microsoft.VisualBasic.DatePart 函數
Day 函數System.DateTime.Day 屬性
Debug.PrintDebug.WriteLine
DeleteSetting 語句Microsoft.VisualBasic.Interaction.DeleteSetting
DoEvents 函數System.Windows.Forms.Application.DoEvents 方法
DrawMode 屬性System.Drawing.Pen.Color 屬性
DrawStyle 屬性System.Drawing.Pen.PenType 屬性
DrawWidth 屬性System.Drawing.Pen.Width 屬性
EnvironMicrosoft.VisualBasic.Interaction.Environ
System.Environment.GetFolderPath
Exp 函數System.Math.Exp 方法
FillColor 屬性System.Drawing.SolidBrush.Color 屬性
FileCopy 語句Microsoft.VisualBasic.FileSystem.FileCopy 函數
System.IO.File.Copy 方法
FileLen 函數System.IO.FileInfo.Length 屬性
Microsoft.VisualBasic.FileSystem.FileLen
FillStyle 屬性System.Drawing.Pen.Brush 屬性
Get 語句Microsoft.VisualBasic.FileSystem.FileGet 函數
GetAttrSystem.IO.File.GetAttributes
GotFocus 事件Enter 事件
GetSetting 語句Microsoft.VisualBasic.Interaction.GetSetting
FileDateTime 函數System.IO.File.GetCreationTime 方法
HasDC 屬性沒有相同項目。
HDC 屬性沒有相同項目。
Height 屬性Control.Size 屬性
Hour 函數System.DateTime.Hour 屬性
hwnd Form1.hwndForm1.Handle 定義處也是 ByVal hWnd As IntPtr
Image 屬性Image 屬性
Input # 語句Microsoft.VisualBasic.FileSystem.Input 函數
InStr 函數System.String.IndexOf
Microsoft.VisualBasic.Strings.InStr 函數
InStrB 函數Microsoft.VisualBasic.Strings.InStr 函數
InStrRev 函數System.String.LastIndexOf 方法
Microsoft.VisualBasic.Strings.InStrRev 函數
Int 函數System.Math.Floor 方法 System.Math.Ceiling 方法
Microsoft.VisualBasic.Int 函數
Integer 類型 Long 類型Dim y As Integer 改為 Dim x As Short
Dim y As Long 改為 Dim y As Integer
IsEmpty 函數Microsoft.VisualBasic.Information.IsNothing 函數
IsDate 函數Microsoft.VisualBasic.IsDate 函數
IsNull 函數Microsoft.VisualBasic.Information.IsDBNull 函數
IsObject 函數Microsoft.VisualBasic.Information.IsReference 函數
Join 函數System.String.Join 方法
KeyAsciie.KeyChar 屬性
Kill 語句Microsoft.VisualBasic.FileSystem.Kill 函數
System.IO 命名空間 FileInfo.Delete 方法
LBound UBoundSystem.Array.GetLowerBound System.Array.GetUpperBound
LCase$ 函數String.ToLower 方法
Microsoft.VisualBasic.Strings.LCase 函數
Left 屬性Control.Location 屬性
Left$、LeftB、LeftB$System.String.SubString
Microsoft.VisualBasic.Strings.Left 函數
LenSystem.String.Length
Microsoft.VisualBasic.Strings.Len
LenBSystem.Text.Encoding.GetEncoding("gb2312").GetByteCount(str1)
System.Text.Encoding.Unicode.GetByteCount("123大小大") '結果 12
System.Text.Encoding.Default.GetByteCount("123大小大") '結果 9
Line 方法System.Drawing.Graphics.DrawLine 方法
Line Input # 語句Microsoft.VisualBasic.FileSystem.LineInput 函數
List1.AddItemListBox1.Items.Add
LoadPicture 函數System.Drawing.Image.FromFile("..\..\test.bmp")
Lock 語句Microsoft.VisualBasic.FileSystem.Lock 函數
Log 函數system.Math.Log 方法
Long 類型 Integer 類型Dim y As Integer 改為 Dim x As Short
Dim y As Long 改為 Dim y As Integer
LostFocus 事件Leave 事件
LTrim$ 函數System.String.TrimStart
Microsoft.VisualBasic.Strings.LTrim 函數
Mid 函數System.String.SubString
Microsoft.VisualBasic.Strings.Mid 函數
MidB 函數Microsoft.VisualBasic.Strings.Mid 函數
Minute 函數System.DateTime.Minute 屬性
MkDir 語句Microsoft.VisualBasic.FileSystem.MkDir 函數
System.IO.Directory.CreateDirectory 方法
MousePointer=11
Screen.MousePointer
System.Windows.Forms.Cursors.WaitCursor()
System.Windows.Forms.Cursor.Current = Cursors.WaitCursor
Mod 運算符Math.IEEERemainder 方法Debug.WriteLine(Math.IEEERemainder(10, 3)) '結果 1
System.Math.DivRem(10, 3, intResult) '結果 3 (10 \ 3)
Debug.WriteLine(intResult) '結果 1 (10 Mod 3)
Month 函數System.DateTime.Month 屬性
MsgBoxSystem.Windows.Forms.MessageBox.Show("Hello, world!")
Microsoft.VisualBasic.MsgBox
Name 語句Microsoft.VisualBasic.FileSystem.Rename 函數
Now 函數System.DateTime.Now Microsoft.VisualBasic.Now
Open 語句Microsoft.VisualBasic.FileSystem.FileOpen 函數
Option Base 語句Visual Basic .NET沒有提供支援。
Option PrivateVisual Basic .NET沒有提供支援。
PaintPicture 方法System.Drawing.Graphics.DrawImage 方法
Point 方法不存在相同的Form和控件。
使用Bitmap時用System.Drawing.Bitmap.GetPixel 方法
Print 方法System.Drawing.Graphics.DrawString 方法
PrintFormVisual Basic .NET沒有提供支援。
Print# 語句Microsoft.VisualBasic.FileSystem.Print 函數
Private 語句
Public 語句
Private Public
Friend Protected Protected Friend
Pset 方法不存在相同的Form和控件。
使用Bitmap時用System.Drawing.Bitmap.SetPixel 方法
Put 語句Microsoft.VisualBasic.FileSystem.FilePut 函數
Replace 函數Microsoft.VisualBasic.Strings.Replace 函數
Right$ 函數、RightB 函數System.String.SubString
Microsoft.VisualBasic.Strings.Right 函數
ReDim 語句ReDim MyArray(5) ReDim Preserve MyArray(15) 語句
RmDir 語句Microsoft.VisualBasic.FileSystem.RmDir 函數 System.IO.Directory.Delete() 方法
Round 函數System.Math.Round 方法
RTrim$ 函數System.String.TrimEnd
Microsoft.VisualBasic.Strings.RTrim
SaveSetting 語句Microsoft.VisualBasic.Interaction.SaveSetting 函數
Scale 方法Visual Basic .NET沒有提供支援。
Screen.ActiveControl
<>ActiveForm
Screen.Fonts
Screen.Height
Screen.MousePointer
Screen.Width
其他 Screen 對象
System.Windows.Forms.Application.ActiveForm.ActiveControl
System.Windows.Forms.Application.ActiveForm
System.Drawing.FontFamilies
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height
System.Drawing.Cursor.Current
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width
其他
Second 函數System.DateTime.Second 屬性
SendKeys 語句System.Windows.Forms.SendKeys.Send("^C")
SetAttrSystem.IO.File.SetAttributes
Sgn 函數System.Math.Sign 函數
ShellMicrosoft.VisualBasic.Shell
Sin 函數System.Math.Sin 函數
Space 函數Microsoft.VisualBasic.Strings.Space 函數
Sqr 函數System.Math.Sqrt 函數
StrComp 函數Microsoft.VisualBasic.Strings.StrComp 函數
StrConv 函數Microsoft.VisualBasic.Strings.StrConv 函數
String$(256, Chr(0))buf = New String(CChar(" "), 256)Microsoft.VisualBasic.Strings.StrDup 函數
StrReverse 函數Microsoft.VisualBasic.Strings.StrReverse 函數
Tan 函數System.Math.Tan 方法
TextHeight 屬性System.Drawing.Font.Height 屬性
TextWidth 屬性System.Drawing.Graphics.MeasureString 方法
Time$ 函數Microsoft.VisualBasic.DateAndTime.Timer 屬性
System.DateTime.Now.TimeOfDay
TimeValue 函數System.DateTime.Parse 方法 CDate 函數
Top 屬性Control.Location 屬性
Trim$ 函數Microsoft.VisualBasic.Strings.Trim 函數
System.String.Trim
Type 語句Structure 語句
UCase$ 函數String.ToUpper 方法
Microsoft.VisualBasic.Strings.UCase 函數
Unlock 語句Microsoft.VisualBasic.FileSystem.Unlock 函數
Unload 事件Closed 事件 Me.Close()
Variant 型Dim x As Variant 改為 Dim x As Object
VarPtr、StrPtr、ObjPtrDim MyGCHandle As GCHandle = GCHandle.Alloc(o,GCHandleType.Pinned)
Dim Address As Integer = CInt(MyGCHandle.AddrOfPinnedObject()) 



當欄位型態為TEXT時,建立TRIGGER的語法


CREATE TRIGGER tr住診病歷摘要記錄A ON 住診病歷摘要檔
INSTEAD OF INSERT
AS
BEGIN
SET NOCOUNT ON
IF (NOT EXISTS (SELECT P.counter FROM 住診病歷摘要檔 P, inserted I WHERE P.counter = I.counter))
insert into 住診病歷摘要暫存檔(工作類別,原counter,住診檔_counter,病摘內容,病摘類別代碼,經手人代號,病摘種類代碼,異動日期時間,確認否,科別代碼)
select 'A',counter,住診檔_counter,病摘內容,病摘類別代碼,經手人代號,病摘種類代碼,異動日期時間,確認否,科別代碼
from inserted
IF (NOT EXISTS (SELECT E.counter FROM 住診病歷摘要檔 E, inserted WHERE E.counter = inserted.counter))
begin
INSERT INTO 住診病歷摘要檔(住診檔_counter,病摘內容)
SELECT 住診檔_counter,病摘內容 FROM inserted
end
END


CREATE TRIGGER tr住診病歷摘要記錄U ON 住診病歷摘要檔
INSTEAD OF update
AS
BEGIN
SET NOCOUNT ON
IF ( EXISTS (SELECT P.counter FROM 住診病歷摘要檔 P, inserted I WHERE P.counter = I.counter))
insert into 住診病歷摘要暫存檔(工作類別,原counter,住診檔_counter,病摘內容,病摘類別代碼,經手人代號,病摘種類代碼,異動日期時間,確認否,科別代碼)
select 'U',counter,住診檔_counter,病摘內容,病摘類別代碼,經手人代號,病摘種類代碼,異動日期時間,確認否,科別代碼
from inserted
IF ( EXISTS (SELECT E.counter FROM 住診病歷摘要檔 E, inserted WHERE E.counter = inserted.counter))
begin
update 住診病歷摘要檔 set
住診檔_counter=I.住診檔_counter,
病摘內容=I.病摘內容
from 住診病歷摘要檔 A join inserted I
on a.counter=I.counter
end
END

Windows Server 2008 / Windows XP 自動登入

1.執行 control userpasswords2
2.選擇要自動登入的使用者名稱,將[必須輸入使用者名稱和密碼,才能使用這台電腦]取消勾選
3.按確定後再輸入正確密碼
4.重開機

Windows Server 2003 自動登入

1.執行 regedit
2.HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\Current Version\Winlogon
 (1)新增字串值 AutoAdminLogon 數值資料:1
 (2)新增字串值 DefaultUserName 數值資料:登入名稱
 (3)新增字串值 DefaultPassword   數值資料:密碼
3.重開機

Windows 遠端重開機

1.net use \\遠端電腦名稱或IP /user:遠端電腦的使用者名稱
然後系統會問密碼,打進去再按ENTER


2.在CMD執行 shutdown -r -m \\遠端電腦名稱或IP