關於我

我的相片
用心思考、保持熱情,把工作上的經驗作分享與紀錄。希望能夠跟大家一起不斷的成長~

javascript get aspnet textbox value

方法如下,請參考
document.getElementById("<%= TextBoxID.ClientID %>").value

刪除oracle user,tablespace,role 等資料

下方以各user,tablespace,role為例,請參考.. 1.步驟1先刪除user cascade的用途為,一併刪除該user相關的資料! 所以會將該user擁有之table一併刪除!
drop user invoice cascade;
drop user exchange cascade;
drop user his cascade;
drop user einvoiceaccount cascade;
drop user einvoicereader cascade;
2.步驟2刪除tablespace 刪除user後,會將其擁有之table,view,procduce..等也一併刪除, 所以現在的tablespace理論上是一個空的表空間
drop tablespace invoice;
drop tablespace exchange;
drop tablespace his;
3.步驟3刪除特殊建立之role..等,如aspnet provider會建立的role!
drop ROLE ORA_ASPNET_MEM_BASICACCESS;
drop ROLE ORA_ASPNET_MEM_FULLACCESS;
drop ROLE ORA_ASPNET_MEM_REPORTACCESS;
drop ROLE ORA_ASPNET_PERS_BASICACCESS;
drop ROLE ORA_ASPNET_PERS_FULLACCES;
drop ROLE ORA_ASPNET_PERS_REPORTACCESS;
drop ROLE ORA_ASPNET_PROF_BASICACCESS;
drop ROLE ORA_ASPNET_PROF_FULLACCESS;
drop ROLE ORA_ASPNET_PROF_REPORTACCESS;
drop ROLE ORA_ASPNET_ROLES_BASICACCESS;
drop ROLE ORA_ASPNET_ROLES_FULLACCESS;
drop ROLE ORA_ASPNET_ROLES_REPORTACCESS;
drop ROLE ORA_ASPNET_SESSN_FULLACCESS;
drop ROLE ORA_ASPNET_SMAP_FULLACCESS;
drop ROLE ORA_ASPNET_WEVNT_FULLACCESS;
此資料庫只有建立自訂的tablespace 並建立user對應新建立之tablespace, 並無對應到其他原有tablespace, 因此只要刪除此兩部份,即可乾淨的環原未新增前狀態! 較特殊的是role 因為有用oracle for aspnet provider, 所以變會建立對應之role 所以也要一併刪除!

EXP / IMP Oracle 資料庫

EXP 資料庫
C:\>exp system/bankpro@oracle9i file=C:\invoice.exp log=C:\invoice.log owner=invoice indexes=y rows=y constraints=y feedback=1000 tts_full_check=y
IMP 資料庫 1.先以具DBA角色權限以上之使用者登入oracle資料庫
C:\>sqlplus system/bankpro@oracle9i
2.執行Script,目的建立TableSpace & User
SQL> start c:\createtablespace.sql;

CREATE TABLESPACE INVOICE DATAFILE
'C:\ORACLE\ORADATA\ORACLE9I\INVOICE.ORA' SIZE 200M AUTOEXTEND ON NEXT 1024M MAXSIZE UNLIMITED
LOGGING
ONLINE
PERMANENT
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 8K
SEGMENT SPACE MANAGEMENT AUTO;

CREATE USER INVOICE
IDENTIFIED BY VALUES 'CC58BA69EDD100F1'
DEFAULT TABLESPACE INVOICE
TEMPORARY TABLESPACE TEMP
PROFILE DEFAULT
ACCOUNT UNLOCK;
-- 17 Roles for INVOICE
GRANT DBA TO INVOICE;
GRANT CONNECT TO INVOICE;
GRANT ORA_ASPNET_MEM_FULLACCESS TO INVOICE WITH ADMIN OPTION;
GRANT ORA_ASPNET_MEM_BASICACCESS TO INVOICE WITH ADMIN OPTION;
GRANT ORA_ASPNET_PERS_FULLACCESS TO INVOICE WITH ADMIN OPTION;
GRANT ORA_ASPNET_PROF_FULLACCESS TO INVOICE WITH ADMIN OPTION;
GRANT ORA_ASPNET_SMAP_FULLACCESS TO INVOICE WITH ADMIN OPTION;
GRANT ORA_ASPNET_MEM_REPORTACCESS TO INVOICE WITH ADMIN OPTION;
GRANT ORA_ASPNET_PERS_BASICACCESS TO INVOICE WITH ADMIN OPTION;
GRANT ORA_ASPNET_PROF_BASICACCESS TO INVOICE WITH ADMIN OPTION;
GRANT ORA_ASPNET_ROLES_FULLACCESS TO INVOICE WITH ADMIN OPTION;
GRANT ORA_ASPNET_SESSN_FULLACCESS TO INVOICE WITH ADMIN OPTION;
GRANT ORA_ASPNET_WEVNT_FULLACCESS TO INVOICE WITH ADMIN OPTION;
GRANT ORA_ASPNET_PERS_REPORTACCESS TO INVOICE WITH ADMIN OPTION;
GRANT ORA_ASPNET_PROF_REPORTACCESS TO INVOICE WITH ADMIN OPTION;
GRANT ORA_ASPNET_ROLES_BASICACCESS TO INVOICE WITH ADMIN OPTION;
GRANT ORA_ASPNET_ROLES_REPORTACCESS TO INVOICE WITH ADMIN OPTION;
ALTER USER INVOICE DEFAULT ROLE ALL;
-- 5 System Privileges for INVOICE
GRANT CREATE SESSION TO INVOICE;
GRANT CREATE ANY TABLE TO INVOICE;
GRANT SELECT ANY TABLE TO INVOICE;
GRANT CREATE ANY PROCEDURE TO INVOICE;
GRANT UNLIMITED TABLESPACE TO INVOICE;
3.開始執行TableSpace的匯入
C:\>imp system/bankpro@oracle9i fromuser=INVOICE touser=INVOICE file=C:\invoice.exp log=C:\invoice.log ignore=y indexes=y rows=y constraints=y feedback=1000
4. 重建Role對應
-- 6 Object Privileges for INVOICE GRANT DELETE, INSERT, SELECT, UPDATE ON  EXCHANGE.COMPANY TO INVOICE;GRANT DELETE, INSERT, SELECT, UPDATE ON  EXCHANGE.SALESINVOICE TO INVOICE;GRANT DELETE, INSERT, SELECT, UPDATE ON  EXCHANGE.SALESINVOICEDETAIL TO INVOICE;GRANT DELETE, INSERT, SELECT, UPDATE ON  EXCHANGE.SALESINVOICENG TO INVOICE;GRANT DELETE, INSERT, SELECT, UPDATE ON  HIS.B2CINVOICEACTIONHISTORY TO INVOICE;GRANT DELETE, INSERT, SELECT, UPDATE ON  HIS.B2CINVOICEDETAILACTIONHISTORY TO INVOICE;
-- 3 Object Privileges for EINVOICEACCOUNT GRANT DELETE, INSERT, SELECT, UPDATE ON  EXCHANGE.COMPANY TO EINVOICEACCOUNT;GRANT DELETE, INSERT, SELECT, UPDATE ON  HIS.B2CINVOICEACTIONHISTORY TO EINVOICEACCOUNT;GRANT DELETE, INSERT, SELECT, UPDATE ON  HIS.B2CINVOICEDETAILACTIONHISTORY TO EINVOICEACCOUNT;
GRANT ORA_ASPNET_MEM_BASICACCESS TO ORA_ASPNET_MEM_FULLACCESS;GRANT ORA_ASPNET_MEM_REPORTACCESS TO ORA_ASPNET_MEM_FULLACCESS;GRANT ORA_ASPNET_PERS_BASICACCESS TO ORA_ASPNET_PERS_FULLACCESS;GRANT ORA_ASPNET_PERS_REPORTACCESS TO ORA_ASPNET_PERS_FULLACCESS;GRANT ORA_ASPNET_PROF_BASICACCESS TO ORA_ASPNET_PROF_FULLACCESS;GRANT ORA_ASPNET_PROF_REPORTACCESS TO ORA_ASPNET_PROF_FULLACCESS;GRANT ORA_ASPNET_ROLES_REPORTACCESS TO ORA_ASPNET_ROLES_FULLACCESS;GRANT ORA_ASPNET_ROLES_BASICACCESS TO ORA_ASPNET_ROLES_REPORTACCESS;
5.重建AspNet Provider
C:\>sqlplus system/bankpro@oralce9i
將建置aspnet provider之script copy至c:\aspnet\路徑下!
SQL> start c:\aspnet\InstallAllOracleASPNETProviders.sql;
6.將有錯誤之procduce & function重新編譯過後即可!

select 包含 Row_Number

查詢所有產品編號,並加上行數!
select Row_Number() over (order by papdno) as RowNt,papdno from pm10d;
[輸出] 1 pdno1 2 pdno2 3 pdno3 . . . 10 pdno10 將行數轉為字串,並補0 select right('00'+ltrim(Row_Number() over (order by papdno)),3) as RowNt ,papdno from pm10d; [輸出] 001 pdno1 002 pdno2 003 pdno3 . . . 010 pdno10

Restore Sql Server 系統資料表Master

因為Master資料表的還原,需要將資料庫伺服器服務啟動於之SingleUser模式, 操作上較為複雜.因此特地將操作步驟寫下~ 1.先停止欲還原之資料庫伺服器服務!如下圖: 2.將資料庫伺服器服務,啟動於SingleUser模式! 於cmd視窗下,輸入指令: "C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn\sqlservr.exe" -m 輸入後會出現一連串的啟動訊息,一般無錯誤訊息發生即完成SingleUser模式之啟動! 3.使用SSMS資料庫管理工具開啟並執行Script,指令如下: RESTORE DATABASE master FROM disk='c:\master.bak' 執行後得到訊息如下圖: 4.停止SingleUser模式之資料庫伺服器! 此步驟只要將剛剛啟動伺服器用的cmd視窗關閉,即停止伺服器服務了! 5.重新啟動資料庫伺服器 此步驟可參考步驟一,選擇啟動之選項即可!

取得sql server系統日期

select getdate();

用Sql分析Profiler錄下之Trace資料

Script如下,參考~ SELECT top 5 substring(TextData,1,100) as SqlCmd, sum(Duration) as Duration, sum(Reads) as Reads, sum(Writes) as Writes, sum(cpu) as cpu, avg(Duration) as AvgDura FROM fn_trace_gettable('C:\Test\deadlock.trc', Default) where TextData is not null group by substring(TextData,1,100) order by AvgDura desc

IOC ( Inversion of Control )

IoC模式基本上是一個高層的概念,在 Martin Fowler 的 Inversion of Control Containers and the Dependency Injection pattern 中談到,實現IoC有兩種方式:Dependency Injection與Service Locator,Spring 所採用的是Dependency Injection 來實現 IoC,中文翻譯為依賴注入,依賴注入的意義是:「保留抽象介面,讓組件依賴於抽象介面,當組件要與其它實際的物件發生依賴關係時,藉過抽象介面來注入依賴的實際物件。」 看看下面這個程式:

public class BusinessObject {
  private FloppyWriter writer = new FloppyWriter();
  ....
  public void save() 
  {
    ...
    writer.saveToFloppy();
  }
} 

BusinessObject 依賴於實際的 FloppyWriter,為了讓 BusinessObject 獲得重用性,不讓 BusinessObject 直接依賴於實際的 FloppyWriter,而是依賴於抽象的介面:

public interface IDeviceWriter 
{
  public void saveToDevice();
} 

public class BusinessObject 
{ 
  private IDeviceWriter writer;
  
  public void setDeviceWriter(IDeviceWriter writer) 
  {
    this.writer = writer;
  }

  public void save() 
  {
    .... 
    writer.saveToDevice();
  }
}

public class FloppyWriter implement IDeviceWriter 
{
  public void saveToDevice() 
  {
    .... // 實際儲存至Floppy的程式碼
  }
} 

public class UsbDiskWriter implement IDeviceWriter 
{
  public void saveToDevice() 
  {
    ....// 實際儲存至UsbDisk的程式碼
  }
} 
如果今天BusinessObject想要與UseDiskWriter物件發生依賴關係,可以這麼建立: businessObject.setDeviceWriter(new UsbDiskWriter()); 由於BusinessObject依賴於抽象介面,在需要建立依賴關係時,可以透過抽象介面注入依賴的實際物件。 依賴注入在Martin Fowler的文章中談到了三種實現方式:Interface injection、Setter injection 與 Constructor injection。並分別稱其為Type 1 IoC、Type 2 IoC 與 Type 3 IoC。 上面的BusinessObject所實現的是Type 2 IoC,透過Setter注入依賴關係,而Type 3 IoC,則在是建構式上注入依賴關係,例如:
public class BusinessObject 
{ 
  private IDeviceWriter writer; 

  public BusinessObject(IDeviceWriter writer) 
  {
    this.writer = writer;
  }

  public void save() 
  {
    ....
    writer.saveToDevice();
  }
} 
Spring 鼓勵的是 Setter injection,但也允許您使用 Constructor injection,使用 Setter 或 Constructor 來注入依賴關係視您的需求而定,使用 Constructor 的好處之一是,您可以在建構物件的同時一併完成依賴關係的建立,然而如果要建立的物件關係很多,則會在建構式上留下一長串的參數,這時使用 Setter 會是個不錯的選擇,另一方面,Setter 可以有明確的名稱可以瞭解注入的物件會是什麼,像是setXXX()這樣的名稱會比記憶Constructor上某個參數位置代表某個物件來得好。 Type 1 IoC是Interface injection,使用Type 1 IoC時會要求實作介面,這個介面是為容器所用的,容器知道介面上所規定的方法,它可以呼叫實作介面的物件來完成依賴關係的注入,例如:
public interface IDependencyInjection 
{
  public void createDependency(Map dependObjects); 
} 

public class BusinessObject implement IDependencyInjection 
{
  private Map dependObjects;
  
  public void createDependency(Map dependObjects) 
  {
    this.dependObject = dependObjects;
    // 在這邊實現與BusinessObject的依賴關係   
    ......
  }
  
  public void save() 
  {
    ....
    writer.saveToDevice();
  } 
} 
如果要完成依賴關係注入的物件,必須實現IDependencyInjection介面,並交由容器管理,容器會呼叫被管理物件的createDependency()方法來完成依賴關係的建立。 在上面的例子中,Type 1 IoC要求BusinessObject實現特定的介面,這就使得BusinessObject依賴於容器,如果日後BusinessObject要脫離目前這個容器,就必須修改程式,想想在更複雜的依賴關係中產生更多複雜的介面,組件與容器(框架)的依賴會更加複雜,最後使得組件無法從容器中脫離。 所以Type 1 IoC具有強的侵入性,使用它來實現依賴注入會使得組件相依於容器(框架),降低組件的重用性。 Spring的核心是個IoC容器,您可以用Setter或Constructor的方式來實現您的業務物件,至於物件與物件之間的關係建立,則透過組態設定,讓Spring在執行時期根據組態檔的設定來為您建立物件之間的依賴關係,您不必特地撰寫一些Helper來自行建立這些物件之間的依賴關係,這不僅減少了大量的程式撰寫,也降低了物件之間的耦合程度。

MSSQL 交易層級改為Snapshot層級

開啟snapshot層級(開啟後會取代原預設Read Commited層級) ALTER DATABASE MyDatabase SET ALLOW_SNAPSHOT_ISOLATION ON; ALTER DATABASE MyDatabase SET READ_COMMITTED_SNAPSHOT ON; 關閉snapshot層級 ALTER DATABASE MyDatabase SET ALLOW_SNAPSHOT_ISOLATION OFF ; ALTER DATABASE MyDatabase SET READ_COMMITTED_SNAPSHOT OFF; --[開啟SNAPSHOT_ISOLATION] ALTER DATABASE VATC4 SET single_user with rollback immediate; go ALTER DATABASE VATC4 SET single_user; go ALTER DATABASE VATC4 SET ALLOW_SNAPSHOT_ISOLATION ON; go ALTER DATABASE VATC4 SET READ_COMMITTED_SNAPSHOT ON; go ALTER DATABASE VATC4 SET multi_user; go --[關閉SNAPSHOT_ISOLATION] ALTER DATABASE VATC4 SET single_user with rollback immediate; go ALTER DATABASE VATC4 SET single_user; go ALTER DATABASE VATC4 SET ALLOW_SNAPSHOT_ISOLATION OFF; go ALTER DATABASE VATC4 SET READ_COMMITTED_SNAPSHOT OFF; go ALTER DATABASE VATC4 SET multi_user; go

SqlServer Cache後的差異

下方為正常執行一張折讓單開立所耗用之時間. 下方為經過SqlServer幫我們Cache後的開立折讓單耗用時間 可以明顯看出來時間上的差異,所以在測試耗用效能時, 必須相當注意,可用下方指令,清除SqlServer的Cache, 保持無Cache狀態測試才有參考價值! DBCC dropcleanbuffers; 當然上方的網頁回應時間數據,也可能是經過網頁伺服器的Cache後, 才有這麼漂亮的數據!

html元件 vs Asp元件onclick事件的不同

<%@ Page Language="C#" AutoEventWireup="true" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <%--JavaScript—%>
    <script type="text/javascript">
         function ClientSideScript() { alert('ClientSide!'); }
    </script>
    <%--Inline Code—%>
    <script language="CS" runat="server">
         protected void ServerSideScript(object sender, EventArgs e) { Response.Write("alert('ServerSide!');"); }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <input type="button" id="Button2" runat="server" value="html_button" onserverclick="ServerSideScript" onclick="ClientSideScript();"      />
            <asp:button          id="Button1" runat="server" Text="aspx_button"  OnClick="ServerSideScript"       OnClientClick="ClientSideScript()" />
        </div>
    </form>
</body>
</html>

可比較上方asp元件與html元件的差異..

ServerSide:OnClick
ClientSide:OnClientClick

ServerSide:onserverclick
ClientSide:onclick

測試code

在 <code> 及 </code> 之間的東西要先做處理。 - 「&」(AND符號) 換成 '&amp;' - 「"」(雙引號) 換成 '&quot;' - 「'」 (單引號) 換成 '&#039;' - 「<」 (小於符號) 換成 '&lt;' - 「>」 (大於符號) 換成 '&gt;'

vs2003升級vs2008 ajax差異

<asp:TextBox ID="_Amount" onkeyup="CheckNumber(this)" ReadOnly="false" name="tbAmount" Style="text-align: right" runat="server" Width="80px" CssClass="InputText"> TextBox之ReadOnly屬性必須為False,否則於javascript改變其值, 並postback回server side時,server side並不會讀取此值!! 此情況於vs2003並不會發生?!不知道其原因!注意之!