2011年6月30日 星期四

增加WordPress 上傳檔案格式 rar

檔案位置
wp-includes/functions.php
搜尋一下內容找到下面這段
'zip' => 'application/zip',
下面加上一樣一行
'rar' => 'application/x-rar',

word 存檔要關閉麥克風? 如何解決

1.開啟Word [工具][選項][存檔]項目
2.先將[內嵌語言資料]勾勾取消
3.[檔案]>[另存新檔]
3.[檔案類型]選[文件範本(*.dot)]
4.選擇存至桌面或您習慣啟動Word的位置,後給一個名稱(例如 [Normal2.dot])
5.以後要啟動Word,就按[Normal2.dot]即可

2011年6月26日 星期日

vs 2010 加快編譯速度

VSSpeedster - Speed up your VS 2010
!Installation:
#. Extract all the files from this archive to the following folder:
C:\Users\UserName\Documents\Visual Studio 2010\AddIns
#. Restart VS
#. Open Tools->Addin Manager
#. Enable VSSpeedster in the Addin Manager (first and second column checkboxes)
#. Now you should get a new button on the "Build" toolbar "Parallel Builds" (icon looks like two parallel lines)
#. Any Build/Run operation will not be run as a parallel build.
You can Turn On/Off the Parallel builds by clicking on the Parallel Builds.
--
使用 vs 2010 開發的有福了,加入此:VSSpeedster 增益集外掛,在開發大型方案時;在編譯上即能節省約1/3時間
--
期待作者能出 vs 2008

2011年6月25日 星期六

利用 xcopy 指令備份資料,並設定排程自動備份

一、Xcopy 常用參數簡介:

/M 只複製設定成保存屬性的檔案,並清除保存屬性。
/S 複製每個目錄及其包含的子目錄,不複製空目錄。
/O 複製檔案所有權及 ACL 資訊。
/C 如果錯誤發生時也繼續複製。
/I 如果目的不存在且複製一個以上的檔案的話,就假設指定的目的一定是目錄。
/H 複製隱藏檔和系統檔。
/K 複製檔案屬性。通常 Xcopy 會重設唯讀的屬性。
/Y 不要提示您確認是否要覆蓋一個已經存在的檔案。
/Q 在複製時不要顯示檔名。

二、備份範例:
Xcopy d:\share e:\backup /M /S /O /C /I /H /K /Y /Q

以上指令是將【D:】磁碟内 share 資料夾完整的複製到【E:】磁碟的 backup 資料夾內,複製時使用增量備份方式(只備份新增或有變更的檔案),且所有檔案的安全權限保持不變。另外,如果路徑中有空白字元或中文字元,且實際測試時無法正確複製,可試試在兩頭使用雙引號,如下:
Xcopy "C:\Documents and Settings\yang\Favorites" "e:\backup" /M /S /O /C /I /H /K /Y /Q

Xcopy "d:\share\公共文件" "e:\backup" /M /S /O /C /I /H /K /Y /Q
以上指令使用記事本輸入後,必須儲存成【BAT】批次檔,才能正常運作。

三、排程設定:
請依序如以下圖示操作,要注意的是第七個步驟要求輸入使用者名稱及密碼,其中密碼需要事先設定好,且一定要輸入,否則排定的工作將無法執行!

2011年6月24日 星期五

在windows下定期制作備份mysql的指令碼

參考來源
---
程式碼:--------------------------------------------------------------------------------
Dim fName,tNow,CMD
tNow = Now()
fName = Year(tNow) & FormatNumber(Month(tNow)/100,2,false) & FormatNumber(Day(tNow)/100,2,false) & FormatDateTime(tNow,3)
fName = Replace(Replace(fName,".",""),":","")
CMD = ""
CMD = CMD & "c:" & vbCrLf
CMD = CMD & "cd c:\mysql\bin" & vbCrLf
CMD = CMD & "mysqldump -u root -p""password"" vbb>d:\bbsbak\backup" & fName & ".sql"
Dim FileObject,BatFile,BatPath
Set FileObject = CreateObject("Scripting.FileSystemObject")
BatPath = "d:\bbsbak\backup.bat"
Set BatFile = FileObject.CreateTextFile(BatPath, True)
BatFile.WriteLine(CMD)
BatFile.Close
Set BatFile = Nothing
Set FileObject = Nothing
Set WshShell = CreateObject("Wscript.Shell")
WshShell.Run BatPath,1,true
Set WshShell = Nothing
--------------------------------------------------------------------------------


把以上程式碼存為backup.vbs,然後你用windows內已含有計劃工作來實現制作備份就行

--opt

制作備份的時候要加上這個參數.....恢復的時候就方便了...對比一下產生的dump文件就會發現增加了那些了...

恢復很簡單...

mysql -u root -p dbname

然後會提示你密碼...

2011年6月23日 星期四

解決 word 卡住

真是糟糕,以前未找到原因;都是此招:alt+ctrl+del
總算找到解決和設定方法了
底下圖照著做即可!

sql 字串相加

declare @a varchar(3)
declare @b varchar(3)
set @a='2'
set @b='3'
print @a+@b

2011年6月22日 星期三

sql 日期條件自動加時間

/*
當資料欄位是屬:日期+時間
參數:@oselday 使用者傳入要查詢的日期期間範圍
*/
declare @oselday datetime
set @oselday ='2011/6/23'
select CONVERT(varchar(10),@oselday,120)+' 00:00:01'

vs 2008 無法開啟 demx

vs 2008 建置 ado.net 實體資料庫模型後,關閉 xml ado.net 實體資料庫模型 後
要在開啟 demx 卻毫無動作.
請下載編譯後,即可 Sample EDMX Code Generator

Net Remoting

使用:Inherits MarshalByRefObject
--
參考1
參考2
參考3
參考4
--
有空再來實作

Sony

Support : Sony Asia Pacific
---
VAIO NB 舊機有福了,sony 終於肯釋出對NB舊機的升級了!!
從Windows xp ~ win7(32/64 bit) 均有!

線上免費製作 Logo

FREE Logo Maker

sql 欄位加入,卸除 PK

--加入PK
ALTER TABLE BOOK ADD CONSTRAINT PK_BOOK PRIMARY KEY CLUSTERED (isdn,bkid,bkname,vipid,bkout)
--卸除PK
ALTER TABLE BOOK drop CONSTRAINT PK_BOOK

2011年6月21日 星期二

sql update 自動累加

參考來源
---
declare @i int
set @i=1
update book set sys_id=@i,@i+=1

sql count null

當 count 欄位是 null 時
但硬是要筆數,就要加入:
select count(null(欄位,0)) from book

如此可防止因null 而少算了筆數

2011年6月20日 星期一

windows XP 啟動過慢

Windows XP 至今還是有在更新,但GUI 和一些Service 就無法與win7相比
啟動就是要等要慢
如下圖:
------
這是不肯等的結果,只好登出才能解除此問題!

2011年6月18日 星期六

在SQL的datetime字段中使用Null值

方法(1)
Dim sqlStmt As String
Dim conString As String
Dim cn As SqlConnection
Dim cmd As SqlCommand
Dim sqldatenull As SqlDateTime
Try
sqlStmt = "insert into Emp (FirstName,LastName,Date) Values (@FirstName,@LastName,@Date) "
conString = "server=localhost;database=Northwind;uid=sa;pwd=;"
cn = New SqlConnection(conString)
cmd = New SqlCommand(sqlStmt, cn)

cmd.Parameters.Add(New SqlParameter("@FirstName", SqlDbType.NVarChar, 11))
cmd.Parameters.Add(New SqlParameter("@LastName", SqlDbType.NVarChar, 40))
cmd.Parameters.Add(New SqlParameter("@Date", SqlDbType.DateTime))

sqldatenull = SqlDateTime.Null

cmd.Parameters("@FirstName").Value = txtFirstName.Text
cmd.Parameters("@LastName").Value = txtLastName.Text
If (txtDate.Text = "") Then
cmd.Parameters("@Date").Value = sqldatenull
'cmd.Parameters("@Date").Value = DBNull.Value
Else
cmd.Parameters("@Date").Value = DateTime.Parse(txtDate.Text)
End If
cn.Open()
cmd.ExecuteNonQuery()
Label1.Text = "Record Inserted Succesfully"

Catch ex As Exception
Label1.Text = ex.Message
Finally
cn.Close()
End Try

方法(2)
Dim sqlStmt As String
Dim conString As String
Dim cn As OleDbConnection
Dim cmd As OleDbCommand
Try
sqlStmt = "insert into Emp (FirstName,LastName,Date) Values (?,?,?) "
conString = "Provider=sqloledb.1;user id=sa;pwd=;database=northwind;data source=localhost"
cn = New OleDbConnection(conString)
cmd = New OleDbCommand(sqlStmt, cn)

cmd.Parameters.Add(New OleDbParameter("@FirstName", OleDbType.VarChar, 40))
cmd.Parameters.Add(New OleDbParameter("@LastName", OleDbType.VarChar, 40))
cmd.Parameters.Add(New OleDbParameter("@Date", OleDbType.Date))

cmd.Parameters("@FirstName").Value = txtFirstName.Text
cmd.Parameters("@LastName").Value = txtLastName.Text
If (txtDate.Text = "") Then
cmd.Parameters("@Date").Value = DBNull.Value
Else
cmd.Parameters("@Date").Value = DateTime.Parse(txtDate.Text)
End If
cn.Open()
cmd.ExecuteNonQuery()
Label1.Text = "Record Inserted Succesfully"

Catch ex As Exception
Label1.Text = ex.Message
Finally
cn.Close()
End Try

2011年6月14日 星期二

字串插入 (非API方式)

---
此為簡易型,若要大量運用;可再加強並寫成函數型 function
此例:是要在"&42 TX"內的空白(space)插入 "-" 符號
CODE:
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a As String = "統一鮮乳 &42 TX"
Dim b As String = ""
TextBox1.Text += a.Length.ToString + vbCrLf
Dim a_insert As Integer = InStr(a, "TX") - 2
TextBox1.Text += a_insert.ToString + vbCrLf
b = Mid(a, 1, a_insert) + "-" + Mid(a, InStr(a, "TX"), a.Length - InStr(a, "TX") + 1)
TextBox1.Text += b
End Sub
End Class

POS 週邊設備文件下載

發票機,BarCode,條碼,條碼機,掃描器,盤點機,RFID

在 IIS7 上執行 PHP

微軟建置參考

2011年6月13日 星期一

藍芽距離

行動通訊網路屬於長距離無線通訊技術,藍芽則歸屬於短距離無線通訊技術(10公尺)
藍芽技術的傳輸距離有10公尺與100公尺兩種,傳輸速率為720Kbps,相當適合使用在個人設備的傳輸上。

ClearPool的用法

參考來源
--
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim ft As GridViewRow = Me.GridView1.FooterRow
Dim tb4 As TextBox = CType(ft.FindControl("TextBox4"), TextBox)
Dim tb5 As TextBox = CType(ft.FindControl("TextBox5"), TextBox)
Dim tb6 As TextBox = CType(ft.FindControl("TextBox6"), TextBox)
Dim objconn As SqlConnection = New SqlConnection("Data Source=1361;Initial Catalog=SFC;Persist Security Info=True;User ID=sa;Password=123456")


objconn.Open()

SqlConnection.ClearPool(objconn)

Dim sql As String = "insert dbo.kentdm(c1,c2,c3) values('" & tb4.Text & "','" & tb5.Text & "','" & tb6.Text & "')"
Dim objcmd As SqlCommand = New SqlCommand(sql, objconn)
Try
objcmd.ExecuteNonQuery()
Me.GridView1.DataBind()
Catch ex As Exception
objconn.Close()
objconn.Dispose()
objcmd.Dispose()
sql = Nothing
Finally
objconn.Close()
objconn.Dispose()
objcmd.Dispose()
sql = Nothing
End Try
GC.Collect()
End Sub

Visual C# Certification

Visual C# Certification, Development, Studio, Training, Tutorials at C# Online.NET
---
又發現新的語言教學網站,真是詳細

2011年6月12日 星期日

3聯式發票稅額計算

'應稅金額-其他付款已開金額 = R應稅金額
'免稅金額-其他付款已開金額(應稅不夠扣除時的其他付款)=R免稅金額
'稅額= R應稅金額-(R應稅金額/1.05)
'銷售額=(R應稅金額)+(R免稅金額)-稅額
'合計= (R應稅金額)+(R免稅金額)

google 提供更多服務的開發平台(java)

Google Code
--
真是心動不以,是開轉向java懷抱了嗎?

2011年6月11日 星期六

Microsoft JET Database Engine 記憶體不足

參考來源
---
http://www.mmkey.com/show.asp?id=8139
http://forums.microsoft.com/MSDN-CHT/ShowPost.aspx?PostID=894404&SiteID=14
http://www.achot.com/Article/112/Article_33514_1.html
有很完整的說明
我照著做都解決了

一個簡單的方法是:
Sql = "select * From [tbname] Where Title like ’%"&keyword&"%’ Order By id Desc"
換成:
Sql = "select * from [tbname] where InStr(1,LCase(Title),LCase(’"&keyword&"’),0)<>0 order by id desc"

我想以後會考慮用utf-8
因為即便只使用中文的web-based資料庫系統
也經常發生很多big5無法支援的特殊字或古字
像很多人的名字因為是特殊字
就無法正確建立基本資料
用utf-8可以解決這些問題
甚至可以用多國語言

**注意**

若有utf-8中文參數值要透過url傳遞時
記得先用Server.URLEncode()把中文參數值編碼
接收參數時不用任何修改會自動解碼

不過要透過URL傳遞參數
建議最好還是使用英文和數字

2011年6月9日 星期四

MDAC - Download and Repair-Page

參考網址
---
1. Install most recent MDAC Version
2. Install Service Pack 8 for the Microsoft Jet 4.0 Database Engine

How to Repair MDAC 2.8 Under Windows XP SP2/SP3

參考網址
----
How to Repair MDAC 2.8 Under Windows XP SP2/SP3
General Information
Windows XP with Service Pack 2 or 3 contains MDAC version 2.81, which is currently not available for download at the Microsoft Web site as a standalone installation. If you try to install MDAC 2.8, which is the latest available standalone download of MDAC, you will receive a message that you already have a newer version of MDAC installed. Therefore, under Windows XP SP2/SP3, you must manually repair MDAC 2.81 as outlined below.

How to Repair MDAC 2.81 under Windows XP with SP2 or SP3
1. In Windows Explorer, open the c:\Windows\Inf folder.

Note If you cannot see the c:\Windows\Inf folder, follow these steps: a. On the desktop, double-click My Computer, and then on the Tools menu, click Folder Options.
b. Click the View tab.
c. Under Advanced settings, select the Show hidden files and folders check box.
d. Clear the Hide extensions for known file types check box.
e. Click OK.


2. In the C:\Windows\Inf folder, right-click the Mdac.inf file, and then click Install.

3. When you are prompted to insert the Windows XP SP2 CD, use one of the following methods: I. If you have a Windows XP SP2 CD:
a. Insert the Windows XP Service Pack 2 CD in the CD or DVD drive.
Note If a "Welcome to Microsoft Windows XP" message appears, click Exit.
b. Click Browse.
c. In the File name box, type CD or DVD drive that contains the Windows XP Service Pack 2 CD drive letter:\i386. For example, type d:\i386 if the Windows XP Service Pack 2 CD is in drive D.
d. Click Open.

II. If you do not have a Windows XP SP2/SP3 CD:
a. In the File name box, type %systemroot%\windows\servicepackfiles\i386, and then click Open.
b. When prompted for adcjavas.inc, point to C:\Windows\servicepackfiles\i386
Note: If you cannot find this folder, put the Windows CD into your CD drive and browse for that file.
c. When prompted for the file handler.reg, either point to C:\Program Files\Common Files\System\msadc, or put the Windows XP CD in your CD-ROM drive.
d. When prompted for MDACRdMe.htm, point to C:\Program Files\Common Files\System\Ado. If this file is not present, rename the file MDACReadme.htm to MDACRdMe.htm.
e. When prompted for oledbjvs.inc, point to C:\Program Files\Common Files\System\Ole DB.
f. When prompted for mssoap1.dll, point to C:\Program Files\Common Files\MSSoap\Binaries.
g. When prompted for mssoapr.dll, point to C:\Program Files\Common Files\MSSoap\Binaries (or below its subfolders).



4. You may also be prompted for the original Windows XP CD that was originally used to install the operating system. a. Insert the Windows XP Service Pack 2 CD in the CD or DVD drive.
Note If a "Welcome to Microsoft Windows XP" message appears, click Exit.
b. Click Browse.
c. In the File name box, type CD or DVD drive that contains the Windows XP Service Pack 2 CD drive letter:\i386. For example, type d:\i386 if the Windows XP Service Pack 2 CD is in drive D.
d. Click Open.

linq 教學(2) group by

--
Imports System.Linq
Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim mm() As Integer = {2, 2, 3, 1, 3, 8, 63, 2}
Dim qm = From xm In mm Select xm Group By xm Into Group
TextBox1.Text = ""
For Each a In qm
TextBox1.Text += a.xm.ToString + " || " + a.Group.ToString + vbCrLf
Next

End Sub
End Class

linq 教學(1) where

--
一般使用linq,若不再搭配其它資料或運用的話;可以用單純的 LINQPad 工具來寫linq
--
Sub Main
dim i() as integer={1,2,3,4,5,6}
dim x =from a in i where a>2 select a
for each b in x
console.writeline(b)
next
End Sub

2011年6月7日 星期二

AutoResetEvent autoEvent.WaitOne

此組指令,運用在POS的週邊設備會較為妥善!
盡量少用 appliation.doevent 或 sleep 或 timer
底下為範例,看大家怎運用!
----------

Imports System
Imports System.Threading

Public Class Form1
Shared autoEvent As New AutoResetEvent(False)
Dim t1 As Date
Dim t2 As Date

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
t1 = Now
TextBox1.Text = ""
Label2.Text = "等待:"
For i As Integer = 0 To 100
TextBox1.Text += i.ToString + vbCrLf
autoEvent.WaitOne(50)
Next
t2 = Now
Label2.Text = "等待:" & (t2 - t1).ToString
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
t1 = Now
TextBox1.Text = ""
Label1.Text = "正常:"
For i As Integer = 0 To 100
TextBox1.Text += i.ToString + vbCrLf
Next
t2 = Now
Label1.Text = "正常:" & (t2 - t1).ToString
End Sub
End Class

AutoResetEvent 運用參考

參考1
參考2
參考3
參考4

取得某檔案的大小

參考1
參考2
---
Public Class Tester
Public Shared Sub Main
Dim fileDetail As IO.FileInfo
fileDetail = My.Computer.FileSystem.GetFileInfo("test.txt")
Console.WriteLine("Size: " & fileDetail.Length & " byte(s)")
End Sub
End Class

2011年6月5日 星期日

BeginTransaction與Commit和Rollback

參考微軟官網
---
引用本篇,主要的作用在:BeginTransaction與Commit和Rollback
POS.ERP等運用在拋轉.轉單.過帳.結轉.結案,運用此方法會較為妥善!
但須思考:近.遠程和效率與頻寬等等的環境因素
---
Private Sub ExecuteSqlTransaction(ByVal connectionString As String)
Using connection As New SqlConnection(connectionString)
connection.Open()

Dim command As SqlCommand = connection.CreateCommand()
Dim transaction As SqlTransaction

' Start a local transaction
transaction = connection.BeginTransaction("SampleTransaction")

' Must assign both transaction object and connection
' to Command object for a pending local transaction.
command.Connection = connection
command.Transaction = transaction

Try
command.CommandText = _
"Insert into Region (RegionID, RegionDescription) VALUES (100, 'Description')"
command.ExecuteNonQuery()
command.CommandText = _
"Insert into Region (RegionID, RegionDescription) VALUES (101, 'Description')"

command.ExecuteNonQuery()

' Attempt to commit the transaction.
transaction.Commit()
Console.WriteLine("Both records are written to database.")

Catch ex As Exception
Console.WriteLine("Commit Exception Type: {0}", ex.GetType())
Console.WriteLine(" Message: {0}", ex.Message)

' Attempt to roll back the transaction.
Try
transaction.Rollback()

Catch ex2 As Exception
' This catch block will handle any errors that may have occurred
' on the server that would cause the rollback to fail, such as
' a closed connection.
Console.WriteLine("Rollback Exception Type: {0}", ex2.GetType())
Console.WriteLine(" Message: {0}", ex2.Message)
End Try
End Try
End Using
End Sub

Enterprise Library 詳細教學網

Enterprise Library 2.0
---
真是利害!!

Enterprise Library 教學網址參考

參考1
Microsoft Enterprise Library 5.0 系列 - 小聪崽的一切 - 博客园
參考2
EntLib - 博客园
參考3
Enterprise Library系列文章回顾与总结 - TerryLee - 博客园
參考4
[24] EntLib - 龙王 - 博客园
參考5(很受用唷)
Enterprise Library 2.0 -- Data Access Application Block - Daniel Pang - 博客园

Enterprise Library 如何使用外部配置文件

網路上這篇真的不多,翻遍所有;就是零散不集中,讓想要用 Enterprise Library 真是有點害怕!
主要是文件過少,大家放出來的經驗值也不高!
底下依此篇Enterprise Library 2.0 技巧 如何使用外部配置文件取精要和重點,只要如此作即可達到"外部配置文件 .config"
---------
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.ExceptionHandling;

static void Main(string[] args)
{
try
{
FileConfigurationSource dataSource = new FileConfigurationSource("data-filesource.config");

DatabaseProviderFactory dbFactory = new DatabaseProviderFactory(dataSource);

Database db = dbFactory.Create("EntLibInstance");

db.ExecuteNonQuery("ProcName");

}
catch (Exception ex)
{
FileConfigurationSource exceptionsSource = new FileConfigurationSource("exceptions-filesource.config");

ExceptionPolicyFactory exceptionFactory = new ExceptionPolicyFactory(exceptionsSource);

ExceptionPolicyImpl exceptionPolicy = exceptionFactory.Create("Event Policy");

if (exceptionPolicy.HandleException(ex))

throw;
}
}
---
以上就祝大家好運,可以開始研究了

Read/Write App.config

請參考來源
--
可要慢慢吸收唷,不錯!!
輔助參考另一篇FileConfigurationSource

以上2篇可花了我1整天才找到,Enterprise Library 實務範例真是不多!!

2011年6月2日 星期四

SQL - 使用 PIVOT

參考來源
--
此範例限:SQL 2005/SQL 2008

Code_1:

Select * From dbo.銷售業績 Order By 年份, 月份

SELECT
年份,
[01] as '一月', [02] as '二月', [03] as '三月', [04] as '四月',
[05] as '五月', [06] as '六月', [07] as '七月', [08] as '八月',
[09] as '九月', [10] as '十月', [11] as '十一月', [12] as '十二月'
FROM (
SELECT 年份, 月份, 銷售量
FROM dbo.銷售業績
GROUP BY 年份, 月份, 銷售量
) as GroupTable
PIVOT
(
Sum(銷售量)
FOR 月份 IN ([01], [02], [03], [04], [05], [06], [07], [08], [09], [10], [11], [12])
) AS PivotTable


Code_2:

Select * From dbo.[銷售業績By季] Order By 年份, 季, 月份

SELECT
年份,
[Q1] as '第一季', [Q2] as '第二季', [Q3] as '第三季', [Q4] as '第四季'
FROM (
SELECT 年份, 季, SUM(銷售量) as '季加總'
FROM dbo.[銷售業績By季]
GROUP BY 年份, 季
) as GroupTable
PIVOT
(
Sum(季加總)
FOR 季 IN ([Q1], [Q2], [Q3], [Q4])
) AS PivotTable

MS-SQL 修改欄位

參考來源
--
ALTER TABLE Table1 ALTER Column T_Column_1 nvarchar(50) NOT NULL

實際:(須注意大小寫,必須和sql一樣)
ALTER TABLE BOOKS ALTER Column note1 varchar(20) NULL