Friday, 19 July 2013

How to Remove Restricted User in SQL Server

execute this query
Use [dbname]
ALTER DATABASE [dbname] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
ALTER DATABASE [dbname] SET MULTI_USER
GO

Friday, 2 November 2012

How to add bookmark on pdf file using itextsharp


 Document document = new Document(PageSize.A4, 50, 50, 25, 25);

            // Create a new PdfWriter object, specifying the output stream
         
            PdfWriter.GetInstance(document, new FileStream(Server.MapPath(“MyFirstPDF.pdf”), FileMode.Create));

            Chapter chapter1 = new Chapter(new Paragraph(“This is Chapter 1″), 1);
            Section section1 = chapter1.AddSection(20f, “Section 1.1″, 2);
            Section section2 = chapter1.AddSection(20f, “Section 1.2″, 2);
            Section subsection1 = section2.AddSection(20f, “Subsection 1.2.1″, 3);
            Section subsection2 = section2.AddSection(20f, “Subsection 1.2.2″, 3);
            Section subsubsection = subsection2.AddSection(20f, “Sub Subsection 1.2.2.1″, 4);
            Chapter chapter2 = new Chapter(new Paragraph(“This is Chapter 2″), 1);
            Section section3 = chapter2.AddSection(“Section 2.1″, 2);
            Section subsection3 = section3.AddSection(“Subsection 2.1.1″, 3);
            Section section4 = chapter2.AddSection(“Section 2.2″, 2);
            chapter1.BookmarkTitle = “Changed Title”;
            chapter1.BookmarkOpen = true;
            chapter2.BookmarkOpen = true;
            document.Add(chapter1);
            document.Add(chapter2);
            // Add the Paragraph object to the doc

How to Share a Link on Twitter


Please click on image and check

please use this code

<img id="ctl00_ctl00_ShareLink1_imgTwitter" border="0" onclick="ShareName('twitter')" src="images/icons/Twitter.png" alt="Twitter" style="border-width:0px;">
:
<script type="text/javascript"> var path = ""; var text = ""; function ShareName(title) { if (title == "twitter") { path = "http://twitter.com/share?url="; text = "&text="; ShareLink(path, text); } } function ShareLink(path, text) { var title = document.title; title = encodeString(title); var url = document.location; url = encodeString(url); var link = url + text + title; link = path + link; window.open(link); return false; } function encodeString(text) { var output = escape(text); output = output.replace("+", "%2B"); output = output.replace("/", "%2F"); return output; } </script>

Monday, 29 October 2012

Online Credit Card Transaction in ASP.NET Using PayPal Pro / dodirect

  string strUsername = "api user name";
            string strPassword = "pasword";
            string strSignature = "signature";
            string strCredentials = "USER=" + strUsername + "&PWD=" + strPassword + "&SIGNATURE=" + strSignature;

            string strNVPSandboxServer = "https://api-3t.sandbox.paypal.com/nvp";
            string strAPIVersion = "50.0";
       
            string strNVP = strCredentials + "&METHOD=DoDirectPayment" +
            "&CREDITCARDTYPE=" + "credit card type"+
            "&ACCT=" + "credit card number" +
            "&EXPDATE=" + "expire date" +
            "&CVV2=" + "cvv number"+
            "&AMT=" + "100" +
            "&FIRSTNAME=" + "Gopal" +
            "&LASTNAME=" + "Singh"+
            "&IPADDRESS= ip address" +
            "&STREET=" + "street" +
            "&CITY=" + "city"+
            "&STATE=" +"state"+
            "&COUNTRY=" + "contry" +
            "&ZIP=" +"1234" + "" +
            "&CURRENCYCODE=GBP" +
            "&PAYMENTACTION=Sale" +
            "&VERSION=" + strAPIVersion;


            try
            {
                //Create web request and web response objects, make sure you using the correct server (sandbox/live)
                HttpWebRequest wrWebRequest = (HttpWebRequest)WebRequest.Create(strNVPSandboxServer);
                wrWebRequest.Method = "POST";
                StreamWriter requestWriter = new StreamWriter(wrWebRequest.GetRequestStream());
                requestWriter.Write(strNVP);
                requestWriter.Close();

                // Get the response.
                HttpWebResponse hwrWebResponse = (HttpWebResponse)wrWebRequest.GetResponse();
                StreamReader responseReader = new StreamReader(wrWebRequest.GetResponse().GetResponseStream());

                //and read the response
                string responseData = responseReader.ReadToEnd();
                responseReader.Close();

                string result = Server.UrlDecode(responseData);

                string[] arrResult = result.Split('&');
                Hashtable htResponse = new Hashtable();
                string[] responseItemArray;
                foreach (string responseItem in arrResult)
                {
                    responseItemArray = responseItem.Split('=');
                    htResponse.Add(responseItemArray[0], responseItemArray[1]);
                }

                string strAck = htResponse["ACK"].ToString();
                Response.Write(strAck);

                if (strAck == "Success" || strAck == "SuccessWithWarning")
                {
                    string strAmt = htResponse["AMT"].ToString();
                    string strCcy = htResponse["CURRENCYCODE"].ToString();
                    string strTransactionID = htResponse["TRANSACTIONID"].ToString();
                    string strSuccess = "Thank you, your order for: $" + strAmt + " " + strCcy + " has been processed.";


                }
                else
                {
                    string strErr = "Error: " + htResponse["L_LONGMESSAGE0"].ToString();
                    string strErrcode = "Error code: " + htResponse["L_ERRORCODE0"].ToString();
           

                }
            }
            catch (Exception ex)
            {
                // do something to catch the error, like write to a log file.
                // Response.Write("error processing");
                //  Response.End();
             
            }

Friday, 12 October 2012

convert text file into csv file in c#


  try
            {

             
                OpenFileDialog dialog = new OpenFileDialog();
                dialog.Title = "Open file as...";
                dialog.Filter = "txt files (*.txt)|*.txt";
                dialog.RestoreDirectory = true;

                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    string csvFileName = dialog.FileName;
                    //get the user to specify the                  
                    TextReader reader = new StreamReader(csvFileName);
                    string a = reader.ReadToEnd();

                    char[] array = a.ToCharArray();

                    reader.Close();
                    MessageBox.Show("File Converted! Please save");

                    SaveFileDialog dialogSave = new SaveFileDialog();
                    dialogSave.Title = "Save file as...";
                    dialogSave.Filter = "CSV files (*.csv)|*.csv";
                    dialogSave.RestoreDirectory = true;

                    if (dialogSave.ShowDialog() == DialogResult.OK)
                    {
                        string saveFile = dialogSave.FileName;
                        //get the user to specify the                



                        FileStream aFile = new FileStream(saveFile, FileMode.OpenOrCreate);

                    StreamWriter sw = new StreamWriter(aFile);

                    for (int i = 0; i < array.Length; i++)
                    {

                        if (array[i] == '\n' && array[i] == '\r')

                            sw.WriteLine();

                        else

                            sw.Write(a[i] + ",");

                    }

                    sw.Close();
                    }
                 
                }



            }
            catch (Exception ex)
            {
                MessageBox.Show("There was an error creating the download report:" + ex.Message);

            }

Thursday, 16 August 2012

Maintaining the ActiveTabIndex of the AJAX Control Toolkit TabContainer after page refresh



call TabManage function  OnClientActiveTabChanged event of ajax tab container

<ajaxToolkit:TabContainer runat="server" ID="Tabs" Height="500px" ScrollBars="Vertical"
                    ActiveTabIndex="0" OnClientActiveTabChanged="  TabManage">


  function TabManage(sender, args) {
                    debugger;
                    sender.get_clientStateField().value =
                sender.saveClientState();
                }

Tuesday, 3 July 2012

how to call indeed api in classic asp


<%@LANGUAGE="VBSCRIPT"%>

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xml:lang="en" lang="en">
<head>

<title>Indeed Api Call</title>
<meta name="title" content="testing" />
</head>
<body>
<div class="vevent">
 
   <%
   dim use
 use=Request.ServerVariables("HTTP_USER_AGENT")
  if request("fj") <>"" then
  as_and=request("as_and")
 as_phr=request("as_phr")
 as_any=request("as_any")
  as_not=request("as_not")
 as_ttl=request("as_ttl")
 as_cmp=request("as_cmp")
 jt=request("jt")
   st=request("st")
  salary=request("salary")
   radius=request("radius")
     l=request("l")
  fromage=request("fromage")
  limit=request("limit")
   sort=request("sort")

Dim req
Set req = Server.CreateObject("MSXML2.ServerXMLHTTP")

req.open "GET", "http://api.indeed.com/ads/apisearch?publisher=9116108067858202&q="&as_and&"&as_phr="&as_any&"&as_not="&as_not&"&l="&l&"&as_ttl="&as_ttl&"&sort="&sort&"&radius=&st="&st&"&jt="&jt&"&start=&limit="&limit&"&fromage="&fromage&"&filter=&latlong=1&co=us&chnl=&userip=1.2.3.4&useragent="&use&"&v=2", False
req.send()

Set objXML = Server.CreateObject("Microsoft.XMLDOM")
 Set objLst = Server.CreateObject("Microsoft.XMLDOM")
 Set objHdl = Server.CreateObject("Microsoft.XMLDOM")
 objXML.async = False
 objXML.Load (req.responseXml)
 Set xml_tree2 = objXML.getElementsByTagName("result")
 dim a:a=req.responseXml.xml
Set xml_tree1 = Nothing
%>
<div style=" min-height:500px; width:500px;">
<%
for i = 0 to (xml_tree2.length - 1)
    set xml_tree3 = xml_tree2.item(i)
    test=    isobject(xml_tree3.childnodes(9))
    IF isobject(xml_tree3.childnodes(9)) AND  isobject(xml_tree3.childnodes(0)) AND  isobject(xml_tree3.childnodes(8)) AND  isobject(xml_tree3.childnodes(16)) AND isobject(xml_tree3.childnodes(17)) THEN
    response.write( "<a href='"&xml_tree3.childnodes(9).text&"' >"&xml_tree3.childnodes(0).text&"</a><br>")
    response.write(xml_tree3.childnodes(8).text&"<bR>")
  response.write(xml_tree3.childnodes(16).text&"<bR>")  
    response.write("<font style='color:#20f120;'>"&xml_tree3.childnodes(17).text&"</font><bR>")
   
   end if
   next


    %>

  </div>
  <% end if %>
</div>
<%   if request("fj") ="" then %>>
<form >

<table cellspacing="0" cellpadding="3" border="0" align="center">
<tbody><tr>
<td><h1>Advanced Job Search</h1></td>
</tr>
<tr>
<td>

<table cellspacing="0" cellpadding="3" border="0">
<tbody><tr><td colspan="2" class="header">Find Jobs</td></tr>
<tr>
<td width="150" nowrap=""><label for="as_and">With <b>all</b> of these words</label></td>
<td><input type="text" value="" maxlength="512" size="35" name="as_and" id="as_and"></td>
</tr>
<tr>
<td nowrap=""><label for="as_phr">With the <b>exact phrase</b></label></td>
<td><input type="text" value="" maxlength="512" size="35" name="as_phr" id="as_phr"></td>
</tr>
<tr>
<td nowrap=""><label for="as_any">With <b>at least one</b> of these words</label></td>
<td><input type="text" value="" maxlength="512" size="35" name="as_any" id="as_any"></td>
</tr>
<tr>
<td nowrap=""><label for="as_not">With <b>none</b> of these words</label></td>
<td><input type="text" value="" maxlength="512" size="35" name="as_not" id="as_not"></td>
</tr>
<tr>
<td nowrap=""><label for="as_ttl">With these words in the <b>title</b></label></td>
<td><input type="text" value="" maxlength="512" size="35" name="as_ttl" id="as_ttl"></td>
</tr>
<tr>
<td nowrap=""><label for="as_cmp">From this <b>company</b></label></td>
<td><input type="text" value="" maxlength="512" size="35" name="as_cmp" id="as_cmp"></td>
</tr>


<tr>
<td nowrap=""><label for="jt">Show jobs of type</label></td>
<td>
<select name="jt" id="jt">
<option value="all">All job types</option>
                         
                            <option value="fulltime">Full-time</option>
                         
                            <option value="parttime">Part-time</option>
                         
                            <option value="contract">Contract</option>
                         
                            <option value="internship">Internship</option>
                         
                            <option value="temporary">Temporary</option>
                         
</select>
</td>
</tr>

<tr>
<td nowrap=""><label for="st">Show jobs from</label></td>
<td>
<select name="st" id="st">
<option value="">All web sites</option>
<option value="jobsite">Job boards only</option>
<option value="employer">Employer web sites only</option>
</select>
</td>
</tr>
<tr>
<td nowrap="">&nbsp;</td>
<td>
<input type="checkbox" value="directhire" name="sr" id="norecruiters">&nbsp;<label for="norecruiters">Exclude staffing agencies</label>
</td>
</tr>





<tr id="sal_item">
<td style="vertical-align:top" class="col_a"><label for="salary">Salary estimate</label></td>
<td><table cellspacing="0" cellpadding="0"><tbody><tr><td><input type="text" size="17" value="" name="salary" id="salary"> per year</td></tr><tr><td><span style="font-size:smaller;color:#666" class="example">$50,000 or $40K-$90K</span></td></tr></tbody></table></td>
</tr>


<tr><td colspan="2" class="header">Where and When</td></tr>
<tr>
<td nowrap="" colspan="1" style="padding:5px 3px;">
                     
<label for="radius"><b>Location</b></label>&nbsp;
<select name="radius" id="radius">


<option value="0">only in</option>






<option value="5">within 5 miles of</option>






<option value="10">within 10 miles of</option>






<option value="15">within 15 miles of</option>






<option value="25" selected="">within 25 miles of</option>






<option value="50">within 50 miles of</option>






<option value="100">within 100 miles of</option>



</select>&nbsp;
                    </td>
                    <td>
<input type="text" value="" maxlength="250" size="28" name="l" id="where" autocomplete="off">&nbsp;(city, state, or zip)

</td>
</tr>
                <tr><td></td><td class=""><div style="position:relative;z-index:2"><div style="display:none;" class="acd" id="acdiv"></div></div></td></tr>
<tr>
<td nowrap="" colspan="2" style="padding:5px 3px;">
<b>Age</b> - <label for="fromage">Jobs published</label>&nbsp;
<select name="fromage" id="fromage">
<option value="any">anytime</option>
                         
                                <option value="15">within 15 days</option>
                         
                                <option value="7">within 7 days</option>
                         
                                <option value="3">within 3 days</option>
                         
                            <option value="1">since yesterday</option>
   <option value="last">since my last visit</option>

</select>
</td>  
</tr>
<tr>
<td nowrap="" colspan="2" style="padding:5px 3px;">
<label for="limit"><b>Display</b></label>&nbsp;
<select name="limit" id="limit">
                         
                            <option value="10" selected="">10</option>
                         
                            <option value="20">20</option>
                         
                            <option value="30">30</option>
                         
                            <option value="50">50</option>
                         
</select>
&nbsp;results per page, <label for="sort">sorted by</label>&nbsp;
<select name="sort" id="sort">
<option value="" selected="">relevance</option>
<option value="date">date</option>
</select>
&nbsp;&nbsp;&nbsp;<input type="submit" value="Find Jobs"  name="fj" id="fj">
</td>
</tr>
</tbody></table>
</td>
</tr>
</tbody></table>
    </form>
    <% end if %>
</body>

</html>