2012年4月6日 星期五

VBA 連線 Access 資料庫

Private Sub CommandButton1_Click()

' mdb 資料庫連線
Dim dbcn As ADODB.Connection
Set dbcn = New ADODB.Connection
dbcn.ConnectionString = "provider=microsoft.jet.oledb.4.0;data source=library.mdb;"
dbcn.Open

' SQL
sqlstr = "select id, 姓名 from users"

' RecordSet
Dim rs1 As ADODB.Recordset
Set rs1 = New ADODB.Recordset

' 執行 SQL
rs1.Open sqlstr, dbcn

' 視窗顯示 Record 內容
If Not rs1.EOF Then
rs1.MoveFirst
    While Not rs1.EOF
        MsgBox CStr(rs1.Fields(0)) + " -> " + CStr(rs1.Fields(1))
        rs1.MoveNext
    Wend
End If

' 關閉資料庫連線
rs1.Close
dbcn.Close

End Sub



Reference :
Access資料庫的連結
Excel VBA 使用 ADO語法連結Access資料庫常用方法
Excel VBA連結資料庫系統---Access資料庫

 

 

MsgBox 型態不符合

為變數形態問題, 須使用變數型態轉換相關函式

CStr
Cint
...




Reference :
轉換型態相關函數

FROM 子句中的語法錯誤

在撰寫 VBA 時, SQL 命令部分報錯, 原來是表格名稱用了 user 為關鍵字

Excel VBA 開發人員 & 啟用巨集

Excel 2007
顯示開發人員索引標籤
Office 圖示 -> Excel 選項 -> 常用 -> 在功能區顯示「開發人員」索引標籤

啟用巨集
Office 圖示 -> Excel 選項 -> 信任中心 -> 信任中心設定 -> 巨集設定 -> 啟用所有巨集

Excel 2010
顯示開發人員索引標籤
檔案 -> 自訂功能區 -> 開發人員打勾

啟用巨集
檔案 -> 選項 -> 信任中心 -> 信任中心設定 -> 巨集設定 -> 啟用所有巨集



Reference :
Excel VBA
[VBA] Excel 2007 啟用巨集 / Enable Marco
設定顯示開發人員索引標籤(Excel 2007/2010)或Visual Basic工具列(Excel 2003)

2012年4月5日 星期四

Windows XP 更改序號

Start -> Run -> oobe/msoobe /a

是,我想要打電話 ...... 啟用 Windows

變更產品金鑰




Reference :
更改XP序號

[系統磁碟工具]RemoveWGA - 微軟 WGA 移除器

jenkins


Started by user anonymous
Building in workspace /var/lib/jenkins/jobs/hello/workspace
Checkout:workspace / /var/lib/jenkins/jobs/hello/workspace - hudson.remoting.LocalChannel@c7aaef
Using strategy: Default
Checkout:workspace / /var/lib/jenkins/jobs/hello/workspace - hudson.remoting.LocalChannel@c7aaef
Cloning the remote Git repository
Cloning repository origin
ERROR: Error cloning remote repo 'origin' : Could not clone user@the_remote_host:hello.git
hudson.plugins.git.GitException: Could not clone user@the_remote_host:hello.git
 設定 ssh 免密碼驗證, 並在命令列下以 jenkins 帳號測試
 git clone user@the_remote_host:hello.git
 (另外, 也可以設定 ssh 自動接受憑證)



Caused by: hudson.plugins.git.GitException: Error performing command: git tag -a -f -m Jenkins Build #4 jenkins-hello-4
Command "git tag -a -f -m Jenkins Build #4 jenkins-hello-4" returned status code 128: 
*** Your name cannot be determined from your system services (gecos).

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

$ git config --global user.email "jenkins@localhost"
$ git config --global user.name "jenkins"


ssh 免密碼登入

Client :
$ ssh-keygen -t rsa
$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
$ scp ~/.ssh/authorized_keys user@REMOTE_HOST:.ssh/








Reference :
SSH 免密碼登入