Showing posts with label Asp.nEt With VB. Show all posts
Showing posts with label Asp.nEt With VB. Show all posts

Saturday, February 4, 2012

Paypal IPN in asp.net VB

' ASP.NET VB

Imports System.Net
Imports System.IO

Partial Class vbIPNexample
Inherits System.Web.UI.Page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Post back to either sandbox or live
Dim strSandbox As String = "https://www.sandbox.paypal.com/cgi-bin/webscr"
Dim strLive As String = "https://www.paypal.com/cgi-bin/webscr"
Dim req As HttpWebRequest = CType(WebRequest.Create(strSandbox), HttpWebRequest)

'Set values for the request back
req.Method = "POST"
req.ContentType = "application/x-www-form-urlencoded"
Dim Param() As Byte = Request.BinaryRead(HttpContext.Current.Request.ContentLength)
Dim strRequest As String = Encoding.ASCII.GetString(Param)
strRequest = strRequest + "&cmd=_notify-validate"
req.ContentLength = strRequest.Length

'for proxy
'Dim proxy As New WebProxy(New System.Uri("http://url:port#"))
'req.Proxy = proxy

'Send the request to PayPal and get the response
Dim streamOut As StreamWriter = New StreamWriter(req.GetRequestStream(), Encoding.ASCII)
streamOut.Write(strRequest)
streamOut.Close()
Dim streamIn As StreamReader = New StreamReader(req.GetResponse().GetResponseStream())
Dim strResponse As String = streamIn.ReadToEnd()
streamIn.Close()

If strResponse = "VERIFIED" Then
'check the payment_status is Completed
'check that txn_id has not been previously processed
'check that receiver_email is your Primary PayPal email
'check that payment_amount/payment_currency are correct
'process payment
ElseIf strResponse = "INVALID" Then
'log for manual investigation
Else
'Response wasn't VERIFIED or INVALID, log for manual investigation
End If
End Sub
End Class

Sunday, December 25, 2011

Bulk Copy Operation


Bulk Copy Operation

This code shows you how to do bulk copy operation using C#.
string connectionString = "";
 using (SqlConnection sc = new SqlConnection(connectionString))
 {
     sc.Open();
 
     SqlCommand commandSourceData = new SqlCommand("SELECT * FROM StoresBackup;", sc);
     SqlDataReader reader =  commandSourceData.ExecuteReader();
     using (SqlConnection dc = new  SqlConnection(connectionString))
     {
         dc.Open();
         using (SqlBulkCopy bulkCopy = new SqlBulkCopy(dc))
         {
              bulkCopy.DestinationTableName = "Stores";
              bulkCopy.WriteToServer(reader);
         }
     }
 }

Tuesday, August 9, 2011

Monday, April 12, 2010

Implementing COM with Visual Basic

All objects must support the IUnknown interface. IUnknown has three methods: 1. AddRef (called when you use the SET statement)
2. Release (called when you set an object variable = Nothing)
3. QueryInterface (checks to see if specific interfaces are supported)
• The IDispatch interface is used to expose an object’s methods and properties. It also inherits
the 3 functions from the IUnknown interface. IDispatch has 4 methods of its own:
1. GetTypeInfo
2. GetTypeInfoCount
3. GetIDsOfNames
4. Invoke
• Late Binding occurs when a reference to a specific object type is not made. In other
words, the variable is declared as type Object as in the following example: Dim objX as
Object
• Declaring a variable as VARIANT is also considered to be late binding.
• Early Binding occurs when a reference is made to a specific object type. At compile
time, the compiler is able to check all object references against information in the object’s
type library. The following is an example of early binding: Dim objY As
ADODB.Command
This type of binding also allows the compiler to optimize access to the object and results in
two types of early binding: dispID binding and Vtable binding. Vtable binding is faster and
more efficient than dispID because it makes fewer method calls to the IDispatch interface.
• The proper syntax for a pop-up menu in Visual Basic is Me.PopupMenu mnuMyMenu.
You can replace Me by the name of the form if you like. This code can be placed in either
the form’s MouseUp or MouseDown event and the menu should be invisible initially.
• An application’s HelpFile can be set programmatically using the Visual Basic APP object.
• The StatusBar control has a panels collection that begins with index 1, not 0. It has two
styles: sbrNormal and sbrSimple. When using the simple style, use the SimpleText prop
erty to provide messages in the one, continuous status bar. If sbrNormal is chosen, on the
other hand, use the Text property to issue messages in one or more of the panels.
• The proper syntax for the TreeView control is:
Treeview.Nodes.Add(Relative], [Relationship], [Key], [Text], [Image], [Selected Image] )as node
• The ListView control can sort information by using the following properties: Sorted,
SortKey and SortOrder.
• DHTML is supported by Microsoft Internet Explorer 4.x or higher. DHTML is a clientbased
solution for applications deployed over the Internet.
• Internet Information Server (IIS) uses web classes and Active Server Pages (ASP). IIS
is a server-side solution for applications deployed over the Internet. Clients using web
browsers make requests to the IIS server and the server replies with responses
(WriteTemplate method, for example).
• DHTML applications generate a .HTM file and a compiled .DLL file.
ActiveX documents generate .VBD and .DLL (or .EXE) files.
• A connection to a database must be established and open before any transactions or execution
statements can be issued: Cnn.Open must precede those which follow
Cnn.BeginTransCmd.Execute