2014年7月2日 星期三

線上信用卡授權程式撰寫方法

http://www.dotblogs.com.tw/johnny/archive/2010/01/19/13129.aspx

有寫過線上信用卡授權程式的人應該都知道如何和對方的 Payment Gateway 溝通。基本上,這種溝通的協定不難理解,反正就是把必要的資訊藏在幾個 Hidden field 裡面,再使用 POST 方式傳到對方指定的網址。
一般來講,銀行端會提供的 HTML 程式碼如下:
1<form id="HPP" action="https://銀行提供的位址" method="post" target="mainFrame">
2    <iframe name="main" id="main" frameborder="0"></iframe>
3    <input type="hidden" name="MID" value="12345" />
4    <input type="hidden" name="TID" value="12345" />
5    ...
6    <input type="hidden" name="Return" value="你自定的接收位址" />
7</form>

如果要使用 ASP.NET 來開發的話,我們會面臨的第一個問題,就是如何把像 MID, TID, Order 號碼等等動態資訊填到上述隱藏的欄位裡。不幸的是,一旦你在上面的 form 裡面加上 runat="server" 文字的話,無論如何,你在 action="..." 填入的網址總是無效,因為它一定只會跳回原來的網頁 (.aspx),而不會跳到授權銀行所指定的那個網頁。
現在,感謝 ASP.NET 2.0 之後所提供的 Cross-page postback 機制,你可以很簡單的在 form 裡面加上一個 Button 控制項,然後再加把銀行提供的那個網址寫在 PostBackUrl 裡面就可以了,如以下範例:
1<form method="post" target="main" runat="server">
2    <iframe name="main" id="main" frameborder="0"></iframe>
3    <input type="hidden" name="MID" value="12345" runat="server" />
4    <input type="hidden" name="TID" value="12345" runat="server" />
5    ...
6    <input type="hidden" name="Return" value="你自定的接收位址" runat="server" />
7    <asp:Button ID="Button1" runat="server" Text="Submit" PostBackUrl="https://銀行提供的位址" />
8</form>

到這裡為止,你應該已經可以成功的在畫面上顯示出銀行的授權畫面了。不過使用這種方法,你會面臨一個不太優雅的小問題,那就是你放在畫面上的那個 Button1 控制項,既沒有辦法寫 Server 端程式讓它變成不顯示 (顯然它不會 Postback 到原網頁),也沒有辦法寫 Client 端程式,以 OnClientClick=... 方法讓它不顯示 (因為會造成 PostBackUrl 沒作用),所以等於會在畫面上多了一個不知如何處理的按鈕物件。
我的解決辦法,就是不讓這個按鈕出現在這一頁上面,而是把它寫在另一頁上面。
所以我在網站中加上一頁,叫做 ShowSomething.aspx,並把原來的網頁改寫如下:
1<form id="Form1" runat="server">
2    <iframe name="main" title="Authorization Page" id="main" src="ShowSomething.aspx" runat="server"></iframe>
3    ...
4</form>

並把 ShowSomething.aspx 網頁寫成如下:
1<form id="Form1" target="main" runat="server">
2    ...
3    <input type="hidden" name="MID" id="MID" value="0100804340" runat="server" />
4    <input type="hidden" name="TID" id="TID" value="70500125" runat="server" />
5    ...
6    <input type="hidden" name="Return" id="Return" value="你自定的接收位址" runat="server" />
7    <asp:Button ID="Button1" runat="server" Text="Server Click!" PostBackUrl="銀行提供的位址" />
8</form>

使用後面這種做法,在 main 這個 iframe 中一開始就帶出 ShowSomething.aspx 網頁中的內容,而當使用者按下其中的 Button1 按鈕後,就會自動帶出銀行的授權畫面,並且把 ShowSomething.aspx 整個覆蓋掉,也就解決了使用第一種方法所造成的問題。
不是每個銀行都採用這種寫法; 事實上愈來愈多銀行或金流業者已經逐漸採用更簡捷方便(也更安全)的寫法了。

取得資料庫欄位值


http://msdn.microsoft.com/zh-tw/library/system.web.ui.webcontrols.gridview.selectedrow(v=vs.110).aspx

Sub CustomersGridView_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)

    ' Get the currently selected row using the SelectedRow property.
    Dim row As GridViewRow = CustomersGridView.SelectedRow

    ' Display the first name from the selected row.
    ' In this example, the third column (index 2) contains
    ' the first name.
    MessageLabel.Text = "You selected " & row.Cells(2).Text & "."
  End Sub

  Sub CustomersGridView_SelectedIndexChanging(ByVal sender As Object, ByVal e As GridViewSelectEventArgs)

    ' Get the currently selected row. Because the SelectedIndexChanging event
    ' occurs before the select operation in the GridView control, the
    ' SelectedRow property cannot be used. Instead, use the Rows collection
    ' and the NewSelectedIndex property of the e argument passed to this 
    ' event handler.
    Dim row As GridViewRow = CustomersGridView.Rows(e.NewSelectedIndex)

    ' You can cancel the select operation by using the Cancel
    ' property. For this example, if the user selects a customer with 
    ' the ID "ANATR", the select operation is canceled and an error message
    ' is displayed.
    If row.Cells(1).Text = "ANATR" Then
        e.Cancel = True
        MessageLabel.Text = "You cannot select " + row.Cells(2).Text & "."
    End If

  End Sub

DetailsView or FormView「新增」一筆記錄時,.FindControl() 事先帶入預設值?...使用ItemCreated事件

從資料庫中讀取值到 RadioButtonList
請問如何從資料庫取值丟給變數

2014年7月1日 星期二

執行階段錯誤'713

http://www.debugease.com/vb/3273832.html

具体:
我做好一程序后,存盘打包,在本机安装可以运行,然后去没能VB的其它电脑上
安装,安装没问题,但运行时却出现色下情况:
执行阶段错误"713"
物件类别没有注册
寻找具有下列CLSID的物件 {000000010-0000-0010-8000-00AA006D2EA4}  就这样,请问我该如何解决???
解决方案 »
用是不是用了第三方组件(就是不是VB自带的组件)?如果是的话,要将第三方组件复制过去,再注册,或在VB打包程序中打包时打进去,因为VB打包程序只会将自带的组件打包

时会打进去,还有什么ACCESS、EXCEL文件等都必须手动打包打进去,我试过都没问题,还有就是注意权限问题,关于数据库要可读写才行。

这是VB的一个BUG(安装SP5也没用),原因是打包时VB没能够将一个必要的动态链接库(Data Report的运行时间文件(Msdbrptr.dll))打包进去,解决方法如下:  1、打开你的工

程,包括对Msdbrptr.dll文件的引用。在引用对话框中,这个文件被列为Microsoft Data Report Designer v6.0。你可能看到Microsoft Data Report Designer v6.0被列出多次

。确保这个应用相关联的文件是Msdbrptr.dll。一旦确定引用了这个文件,重新运行向导制作安装包。 2、在使用Package and Deployment Wizard (PDW)制作安装盘时手工加入

Msdbrptr.dll。当运行PDW时,在Included Files对话框中添加这个文件并重新建立安装包。


http://support.microsoft.com/kb/248055/zh-tw

若要解決這個問題,請使用下列方法之一:
開啟您的專案,並包含 Msdbrptr.dll 檔案的參考。這個檔案會列為 [參考] 對話方塊中的Microsoft 資料報表設計師 6.0 。您可能會看到一次以上列出的Microsoft 資料報表設

計師 6.0 。請確定與參考相關聯的檔案是 Msdbrptr.dll。一旦經過驗證的參考,請重建您的安裝套件。

-或者-
以手動方式將 Msdbrptr.dll 檔案納入 「 封裝暨部署精靈 」 (PDW)。您可以手動加入該檔案中包含的檔案對話方塊的視窗執行 PDW 時再重新建立安裝套件。
在安裝之後,下列檔案應該存在於指定的資料夾中的目標系統上:
< windows 系統 > \Msdbrptr.dll
< 程式檔案 > \Common Files\Designers\Msderun.dll
< windows 系統 > \Msstdfmt.dll
Msdbrptr.dll (和其相依的檔案) 包含通常用來更正這個問題。如果您仍然遇到問題,請確定下列檔案會包含在套件中:
Msdatrep.ocx
Msbind.dll
資料報表不直接依賴這些檔案。不過,如果檔案遺失,這可能會影響您的報表由資料環境。

附註: 如果您的應用程式必須具有 Msdatsrc.tlb 檔案,不要明確包含這個檔案因為 Msdatsrc.tlb 安裝 Microsoft 資料存取元件 (MDAC) 升級的一部份。


http://tlcheng.twbbs.org/myinfobox/zdisqvb6p2/post014972.htm

執行階段錯誤'713':
物件類別沒有註冊。
尋找具有下列CLSID物件:{00000010-0000-0010-8000-00AA006D2EA4}
-
請問出現這樣是我封裝時出了什麼錯誤嗎??

使用到的物件要一併封裝進去!!!
你遺漏的物件是: DAO.DBEngine

原始網頁:http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q209805&ID=KB;EN-US;Q209805&

CAUSE

ISAM drivers are used by Access to update file formats other than its own. If the path to the ISAM driver in your Windows Registry is not valid, or if the ISAM driver does not exist, you may receive the following error messages:

Could not find installable ISAM
-or-
The wizard is unable to access information in the file ''. Please check that the file exists and that the file is in the correct format. 

RESOLUTION

To correct the problem, you can try to register the file manually or you must correct path name errors in the Windows Registry, and then install or replace the problem file.

In the case of the first error message, the file name is directly related to the attempted operation.

In the case of the second error message, the file name is mentioned in the text of the message.

1.Locate the relevant file in the following table:File Name Import/Export ISAM for: Windows Registry
Msexcl40.dll Microsoft Excel HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Excel
Msexch40.dll Microsoft Exchange HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Exchange
Msrd2x40.dll Microsoft Jet 2.x HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Jet 2.x
Msrd3x40.dll Microsoft Jet 3.x HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Jet 3.x
Msltus40.dll Lotus 1-2-3 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Lotus
Mspbde40.dll Imprise Paradox HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Paradox
Mstext40.dll Text HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Text
Msxbde40.dll dBase HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Jet\4.0\Engines\Xbase

2.Use Microsoft Windows Explorer to search for the file.

3.If the file is found, record the path name for the file. If the file is not found, go to step 13.
4.Open the Windows Registry Editor.

WARNING: If you use Registry Editor incorrectly, you may cause serious problems that may require you to reinstall your operating system. Microsoft cannot guarantee that you can solve problems that result from using Registry Editor incorrectly. Use Registry Editor at your own risk.

5.Move to the registry subkey that is described in the table, and then check the path name against the actual path name. If the registry key does not exist, go to step 8.

6.Correct the path name if it is incorrect. Continue with these steps if it is correct.

7.Close Registry Editor. If you changed the path name, repeat the process that produced the original error.

8.If the error persists, try to manually register the file by using the Regsvr32.exe utility. Regsvr32.exe is an application that is used to register dynamic-link libraries (DLLs) and ActiveX controls in the Windows registry. You can use this file to stop the issue of mismatched .dll files. To start to re-register your .dll files by using Regsvr32.exe go to the next step.

9.Verify that the Regsvr32.exe file is in the system folder where Windows is installed, for example:
C:\Windows\System
-or-
C:\Winnt\System32

10.Click Start, and then click Run.

11.In the Run dialog box, type the following command in the Open list.

NOTE: The path to Regsvr32.exe and the name and the path of the DLL may be different on your computer. The following example command registers the Excel ISAM:

Regsvr32 c:\winnt\system32\msexcl40.dllNOTE: Another method of registering DLLs is to use Windows Explorer to find the DLL. Double-click the DLL. In the Open With dialog box click to select Regsvr32.exe and then click OK. This creates a permanent association of all DLLs with Regsvr32.exe. You can easily register other unregistered DLLs by double-clicking them.

For additional information about how to obtain this file, click the article number below to view the article in the Microsoft Knowledge Base:
267279 ACC2000: Regsv32a.exe Available in Download Center

12.If the error persists, or if the path name was correct in step 5, rename the file.

13.Start the Add/Remove Programs tool, start the Office 2000 Setup program, and then click to select the Repair Office option.