Wednesday, December 14, 2011

Dynamic insert into variable table statement SQL Server


Table:
DECLARE @A_Table TABLE(ID INT, att1 VARCHAR(100), att2 nvarchar(200))
Then,I need to make dynamic sql statement, so I insert into this table some data (all inside a loop):
WHILE (@i <= 100) BEGIN         
  SELECT @other_att  = NAME  FROM @other_Table where ID =  @i;
  SET @sql = 'INSERT ' + @A_Table+ '(ID,att1,att2) SELECT '+CAST(@i AS VARCHAR)+' , '''+ @other_att+''', SUM('+ @other_att') FROM '+ @EVEN_OTHER_Table;
EXEC (@sql);
END 

Tuesday, December 13, 2011

How do I get the height and width of a pdf file


When creating your PDF please use either our supplied Plug-in for correct specs or our book size specification calculator (if you are using a different creation tool) to determine exact page and cover sizes. Otherwise, although you might be able to upload your PDF, it will fail the post-upload preflight check.

There are few ways to determine the width and height of your existing PDF.  
1. Launch and open your PDF with Adobe Reader
2. From the menus choose File > Properties
3. The Document Properties window will be presented
4. Under the "Description" tab, near the bottom of the window you will see the "Page Size" label
5. This is the width and height of your PDF in the preferred units. You can change the unit of measurement if desired in the Reader preferences under the "Units" section.

To change your PDF dimensions you will need to return to your original design application and adjust the page size from there. Once your PDF dimensions are set, you can proceed to upload.

Wordpress Notice PopUp


I Give Away My Popup Opt-in Form plug-in for Wordpress FREE!

Hi fellow marketers,
If you’re one of the blogger who cares about building list in your niche market.
You may feel pain when you want to setup a cool popup opt-in form in your blog.
Other of that, you may want it to …
- Automatically pop-up when the page was loaded, using a cool effect.
- Put the same opt-in form in any place in your blog.
- Put the cover image and popup opt-in form when visitor click on it.
If you’re using Wordpress as your blog platform and using Aweber as autoresponder system.
Don’t miss this cool plug-in.
No risk as I give you for FREE!
If you want to build your list on your blog but don’t have autoresponder yet. Just click here.

Wednesday, November 9, 2011

palindromic string that retrieve value from the braces


public static bool IsPalindrome(string s)
{
    int iLength, iHalfLen;
    iLength = s.Length - 1;
    iHalfLen = iLength / 2;
    for (int i = 0; i <= iHalfLen; i++)
    {
        if (s.Substring(i, 1) != 
            s.Substring(iLength - i, 1))
        {
            return false;
        }
    }
    return true;
}

static void Main(string[] args)
{
    Console.WriteLine("\nPalindromes?");
    string[] sa = new string[]{
        "level", "minim", "radar", 
        "foobar", "rotor", "banana"};

    foreach (string v in sa)
        Console.WriteLine("{0}\t{1}", 
            v, StringEx.IsPalindrome(v));
}
OUTPUT
Palindromes?
level   True
minim   True
radar   True
foobar  False
rotor   True
banana  False

Wednesday, November 2, 2011

How to create a column that will autogenerate


If it is just for display, not for changing the serial number in the database, try a TemplateField column like this:

C# Example:
<asp:TemplateField HeaderText="S.NO">    <ItemStyle Width="30px" />
                                     <ItemTemplate>
                                       <%# Container.DataItemIndex + 1 %>.&nbsp;
                                     </ItemTemplate>
                        </asp:TemplateField>

VB.Net Example:

VB.NET:
<asp:TemplateField HeaderText="S.No" >
   <ItemTemplate>   
       <%# CType(Container, GridViewRow).RowIndex + 1%>
   </ItemTemplate>
</asp:TemplateField>
C#:

Tuesday, November 1, 2011

Export Gridview to Excel in asp.net

//In Button Click


HtmlForm form = new HtmlForm();
        string attachment = "attachment; filename=Report.xls";
        Response.ClearContent();
        Response.AddHeader("content-disposition", attachment);
        Response.ContentType = "application/ms-excel";
        StringWriter stw = new StringWriter();
        HtmlTextWriter htextw = new HtmlTextWriter(stw);
        form.Controls.Add(GridView1);
        this.Controls.Add(form);
        form.RenderControl(htextw);
        Response.Write(stw.ToString());
        Response.End();

Thursday, October 13, 2011

Diffrent Date Time format



SQL Query = SELECT CONVERT(VARCHAR(10),GETDATE(),111)
Result=2011/10/13

SQL Query =  SELECT DISTINCT CONVERT(VARCHAR(11),(date)) FROM user_log
Result=Oct 11 2011

SQL Query =SELECT Convert(char(2),DATEPART(hour, GETDATE())) + ':'+convert(char(2),datepart(mi,getdate())) + ':' + convert(char(2),datepart(s,getdate()))
Result=11:20:36

SQL Query = select substring(convert(varchar(20),date),12,8) as TheTime FROM user_log
Result=10:31PM

Tuesday, October 11, 2011

UserControl Enable and Disable in asp.net

Hi,

        //    In Page_Load


          uname = Page.User.Identity.Name;// Find the user Role who is logged in
        Control admin = Page.FindControl("~/_controls/UC1");
        Control user = Page.FindControl("~/_controls/UC2");
        if (Roles.IsUserInRole("Admin"))
        {
                ((UserControl)AdminMenu1).Visible = true ;
                ((UserControl)UserMenu1).Visible = false;
                Panel_status.Visible = true;
                 
        }
        else if (Roles.IsUserInRole("User"))
        {
         
            ((UserControl)UC1).Visible =false;
            ((UserControl)UC2).Visible = true;
            Panel_status.Visible = false;

        }

Thursday, September 29, 2011

how to get textbox value in jquery


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="jQuery1.aspx.cs" Inherits="jQuery1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>How to read TextBox value using JQuery</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox runat="server" ID="txtFirst"></asp:TextBox>
        <asp:TextBox runat="server" ID="txtSecond"></asp:TextBox>
        <asp:Button runat="server" ID="btn" Text="+" />
        <asp:TextBox runat="server" ID="txtSum"></asp:TextBox>
    </div>
    </form>
</body>
</html>



<script language="javascript">
            $(document).ready(function() {        

                $('#btn').click(function() {
                    // Read First number & 2nd Number from TextBox
                    var $nFirstNum = parseInt($('#txtFirst').val())
                    var $nSecondNum = parseInt($('#txtSecond').val())
                    var $nResult = $nFirstNum+$nSecondNum               
                    // Set the result into txtSum TextBox
                    $('#txtSum').val($nResult)
                    return false;
                });
            });
    </script>