Step 1: Add Reference-> COM->Microsoft Excel 12 Library
Step 2:
Dim xlApp As Microsoft.Office.Interop.Excel.Application
Dim xlBook As Microsoft.Office.Interop.Excel.Workbook
Dim xlSheet As Microsoft.Office.Interop.Excel.Worksheet
Public Sub WriteExcel()
xlApp = CType(CreateObject("Excel.Application"), Microsoft.Office.Interop.Excel.Application)
xlBook = CType(GetObject("c:\book3.xls"), Microsoft.Office.Interop.Excel.Workbook)
xlSheet = CType(xlBook.Worksheets("Sheet1"), Microsoft.Office.Interop.Excel.Worksheet)
' Show the sheet.
xlSheet.Activate()
xlSheet.Visible = Microsoft.Office.Interop.Excel.XlSheetVisibility.xlSheetVisible
'Enter Data
xlSheet.Cells(4, 2) = "test"
xlSheet.Cells(4, 3) = "Dummy"
xlBook.Save()
xlBook.Close()
'xlApp.Quit to close the work sheet.
xlApp.Quit()
End Sub
3366b244-8c7b-4a01-b509-892e3fbdd18e|0|.0
Use the following function for verification
Function PostToPayPal(ByVal sTX As String) As String
Dim tx, PDTvalidateQuery, token As String
Dim strResponse As HttpWebResponse
Dim temp As String
'Dim PDTArray() As String
Dim iParts, sResults(0, 0), aParts(), sParts(), sKey, sValue As String
Dim i As Integer
Dim firstname, lastName, itemName, mcGross, mcCurrency As String
'production WRF token
token = "1jGOL41IoO4KqBBdl51borXO8eavZoYzyIFcd0H69c1ZShsxK6JD0fZDm5i"
'test token
'token = "pAsF96B7LJPK2k4fsa-oHQR-tyQl-Bu9gKxi7DH72svl3K-UbT0ETGVCJqS"
tx = sTX
'set string = to the cmd value, tx and at that needs to be POSTed back to PayPal to validate the PDT
PDTvalidateQuery = "cmd=_notify-synch&tx=" & tx & "at=" & token
'Now we need to POST this info back to PayPal for validation of the PDT. Create the request back:
Dim req As HttpWebRequest = CType(WebRequest.Create("https://www.paypal.com/cgi-bin/webscr"), HttpWebRequest)
'Dim req As HttpWebRequest = CType(WebRequest.Create("https://www.sandbox.paypal.com/cgi-bin/webscr"), HttpWebRequest)
' Set values for the request back
req.Method = "POST" 'set method
req.ContentType = "application/x-www-form-urlencoded"
req.ContentLength = PDTvalidateQuery.Length
' Write the request back to PayPal
Dim stOut As StreamWriter = New StreamWriter(req.GetRequestStream(), Encoding.ASCII)
stOut.Write(PDTvalidateQuery)
stOut.Close()
Try
strResponse = CType(req.GetResponse(), HttpWebResponse)
Catch ex As SystemException
LogError(ex)
End Try
'Once we write the stream back to PayPal, we need to read the
'response.
Dim IPNResponseStream As Stream = strResponse.GetResponseStream
Dim encode As Encoding = System.Text.Encoding.GetEncoding("utf-8")
Dim readStream As New StreamReader(IPNResponseStream, encode)
'read the response intoa String variable "temp"
temp = readStream.ReadToEnd
'Check to see if the 1st line of the response was "SUCCESS"
Dim strOutput As String
If Mid(temp, 1, 7) = "SUCCESS" Then
'if it is SUCCESS, the code below puts the
'response in a nice array
temp = Mid(temp, 9)
sParts = Split(temp, vbLf)
iParts = UBound(sParts) - 1
ReDim sResults(iParts, 1)
For i = 0 To iParts
aParts = Split(sParts(i), "=")
sKey = aParts(0)
sValue = aParts(1)
sResults(i, 0) = sKey
sResults(i, 1) = sValue
'add more case statements here in order to access other returned variables
Select Case sKey
Case "first_name"
firstname = sValue
Case "last_name"
lastName = sValue
Case "item_name"
itemName = sValue
Case "mc_gross"
mcGross = sValue
Case "mc_currency"
mcCurrency = sValue
End Select
Next
strOutput = "<h2><b>Thanks for your Order!!</b></h2><br><br>"
strOutput += "<li>Name: " & firstname & " " & lastName & "</li>"
strOutput += "<li>Description: " & itemName & "</li>"
strOutput += "<li>Amount: " & mcCurrency & " " & mcGross & "</li>"
'debug
'OutputEntirePDTString(temp)
Else
' IF PDT response is "FAIL" - investigate
strOutput = "Error - PDT FAIL"
End If
'close opened streams
readStream.Close()
strResponse.Close()
PostToPayPal = strOutput
End Function
52572f40-d7a3-41b2-9b90-5bce97b39566|0|.0
When you attempt to verify PDT transaction data by posting a _notify-synch command. However, in 9 times out of 10 the cause is due to the request containing an incorrect ‘at’ or authorisation token argument.
The ‘authorisation token’, or ‘Identity Token’ is a big long alphanumeric string, to find yours log into your paypal account, click on ‘Profile’, then click on ‘Website Payment Preferences’, scroll down to the ‘Payment Data Transfer’ section – you will see your ‘Identity Token’ at the end of this section.
This token must be included in your _notify-synch command as an argument named ‘at’.
e630e51d-6cfb-4c3b-a4a8-30c0f9a928ba|0|.0
Alter Table Names
Add Id_new Int Identity(1, 1)
6957f8c3-b213-463f-bc09-b625c989555e|0|.0
It is due to the fact you might have used DynamicField in GridView
To be able to use Dynamic Data you need to add a Data Model to your project, either in the form of LINQ to SQL or an Entity Framework data model.
changing columns from something like so:
<Columns>
<asp:DynamicField DataField="Id" HeaderText="Id" />
</Columns>
to this:
<Columns>
<asp:BoundField DataField="Id" HeaderText="Id" />
</Columns>
474fd6c8-118d-4d46-b7ee-4d721b63453c|0|.0