Tuesday, October 25, 2011

SQL Queries

REset the Identiy Column to Zero

==================================================
DBCC CHECKIDENT ( tbl_MOduleImages,RESEED,0)

Synatx :
DBCC CHECKIDENT (tbl_name,RESEED,0)


 ------------------------
Copy a table from another Database to current database:

SELECT * INTO Login_AtemptsCheck  FROM DashBoard.dbo.Login_AtemptsCheck
1) Login_AtemptsCheck: Is a New table name in current database
2) DashBoard: Existing database from where we take the table

3)dbo.Login_AtemptsCheck: Tbale name from the database DashBoard which contains data


 Example 2:
select * into new_Table_Name from DataBase_Name.Exixting_Table_Name
=======================================================================
Sql Error handling
http://www.mssqltips.com/sqlservertip/1027/sql-server-2005-try-and-catch-exception-handling/

=====================================================================
Geometry  Data Type in sql Example
http://www.freddes.se/2008/09/25/net-and-spatial-data-with-sql-server-2008-part-1/
2) http://robertoschiabel.wordpress.com/2011/03/16/locations-in-this-area-sql-server-geography-datatype/

Friday, October 21, 2011

Dynamic Table Creation



Table tb = new Table();
    tb.ID = "myTable";
    tb.Height = Unit.Pixel(200);
    tb.Width = Unit.Pixel(200);
    tb.BorderWidth = Unit.Pixel(3);
    tb.CellPadding = 2;
    tb.CellSpacing = 2;
    for (int i = 0; i < 3; i++)
    {
        TableRow tr = new TableRow();
        tr.ID = "row" + i.ToString();
        for (int j = 0; j < 2; j++)
        {
            TableCell tc = new TableCell();
            tc.ID = "cell" + i.ToString() + j.ToString();
            tc.Text = "cell" + i.ToString() + j.ToString();
            tr.Cells.Add(tc);
        }
        tb.Rows.Add(tr);
    }
    form1.Controls.Add(tb);


reference:
http://www.codeproject.com/KB/aspnet/DynamicServerControls.aspx

Wednesday, October 12, 2011

DataList in ASp.net

http://forums.asp.net/t/1162928.aspx/1


Re: how to find control from header template of a datalist?

Jan 04, 2010 07:28 AM | LINK
Instead of  finding  the control in the header template of datalist in page load event .you can put the code which you want to execute after finding the control inside a function and then call that function from the header template.Below is a example:->
<asp:DataList ID="dtlisFirstSubCategories" runat="server">
        <HeaderTemplate>
            <%#GetParentCategoryName() %>
        </HeaderTemplate>
        <ItemTemplate>
            <asp:LinkButton ID="lbtnSubCategory" runat="server" CommandArgument='<%#Eval("ProductCategoryID")%>'
                Text='<%#Eval("Name")%>'  PostBackUrl='<%#"~/Category.aspx?parentCategoryID="+Eval("ProductCategoryID") %>'
                OnClick="lbtnSubCategory_Click"> </asp:LinkButton>
        </ItemTemplate>
    </asp:DataList>


now in cs file you can put code as follows:->
public string GetParentCategoryName()
    {
String parentCategoryName="";    
  //add logic here to get the category name

return parentCategoryName;
    }