How to count the total records of a table in SQLServer2008R2 fast way

SELECT
Total_Rows= SUM(st.row_count)
FROM
sys.dm_db_partition_stats st
WHERE
object_name(object_id) = ‘Table_name’ AND (index_id < 2)

Posted in Sqlserver | Leave a comment

PayPal Integration on Asp.Net 3.5 C#

com.paypal.sdk.services.NVPCallerServices caller = new com.paypal.sdk.services.NVPCallerServices();
com.paypal.sdk.profiles.IAPIProfile profile = com.paypal.sdk.profiles.ProfileFactory.createSignatureAPIProfile();
/*
WARNING: Do not embed plaintext credentials in your application code.
Doing so is insecure and against best practices.
Your API credentials must be handled securely. Please consider
encrypting them for use in any production environment, and ensure
that only authorized individuals may view or modify them.
*/

// Set up your API credentials, PayPal end point, API operation and version.

profile.APIUsername = ConfigurationManager.AppSettings.Get(“API_USERID”);

profile.APIPassword = ConfigurationManager.AppSettings.Get(“API_PASSWORD”);

profile.APISignature =ConfigurationManager.AppSettings.Get(“API_SIGN”);
profile.Environment = ConfigurationManager.AppSettings.Get(“API_ENV”);//Sandbox | Live

caller.APIProfile = profile;

com.paypal.sdk.util.NVPCodec encoder = new com.paypal.sdk.util.NVPCodec();
encoder[“VERSION”] = “51.0”;
encoder[“METHOD”] = “DoDirectPayment”;

// Add request-specific fields to the request.
encoder[“PAYMENTACTION”] = paymentAction;
encoder[“AMT”] = amount;
encoder[“CREDITCARDTYPE”] = creditCardType;
encoder[“ACCT”] = creditCardNumber;
encoder[“EXPDATE”] = expdate_month;
encoder[“CVV2″] = cvv2Number;
encoder[“FIRSTNAME”] = firstName;
encoder[“LASTNAME”] = lastName;
encoder[“STREET”] = address1;
encoder[“CITY”] = city;
encoder[“STATE”] = state;
encoder[“ZIP”] = zip;
encoder[“COUNTRYCODE”] = countryCode;
encoder[“CURRENCYCODE”] = currencyCode;

// Execute the API operation and obtain the response.
string pStrrequestforNvp = encoder.Encode();
string pStresponsenvp = caller.Call(pStrrequestforNvp);

com.paypal.sdk.util.NVPCodec decoder = new com.paypal.sdk.util.NVPCodec();
decoder.Decode(pStresponsenvp);
string a=decoder[“TransactionID”];
paymentInfo.RESPONSE_TEXT = decoder[“ACK”];
return decoder[“ACK”];

Posted in Asp.Net, Paypal | Tagged , | Leave a comment