Posts filed under ‘Database’

SQL 分頁

SQL

九月 24, 2009 at 2:26 下午 Leave a comment

Restore Indentity/auto number to 1

in the database, we would like to restore the identity back to 1, we can use the following methods:

1) drop table and recreate again

2) restore the identity to false and get back to true

3) type this sql:

DBCC CHECKIDENT(‘TableNAME’, RESEED, 1)

:) the last one is taught by Ricky

八月 28, 2009 at 2:15 下午 Leave a comment

SQL IN Statement with variable/parameter

DECLARE @OrderList varchar(500)

SET @OrderList = ”’admin”, ”Brand Guest”’     //呢度係 ‘  ‘   ‘   , 3 個’ 組成~~

DECLARE @SQL varchar(600)

SET @SQL = ‘SELECT * FROM [WebDB].[dbo].[A_LoginTrack]WHERE LT_LOGNAME IN (‘ + @OrderList + ‘)’

PRINT @SQL   // print sql statement

EXEC(@SQL)

八月 3, 2009 at 6:10 下午 Leave a comment

Datalist ([Eval("XXX") ])

<asp:DataList ID=”DataList3″ runat=”server” DataSourceID=”SqlDataSource3″ RepeatColumns=”4″ CellPadding=”20″ CellSpacing=”20″
                ShowFooter=”False” ShowHeader=”False”>
                <HeaderTemplate>
               
                </HeaderTemplate>
                <ItemTemplate>
                    <a href=’<%# Eval(“AP_LINK”, “?getgroup=”)%><%# Eval(“AP_PAGEGROUP”) %>’ rel=’lightbox[<%# Eval("AP_THUMB") %>]‘ id=’<%# Eval(“AP_UID”) %>’
                        title=’<%# Eval(“AP_ALT”) %>’>
                        <img src=’<%# Eval(“AP_THUMB”, “images/press/{0}”)%>’ alt=’<%# Eval(“AP_ALT”) %>’ title=’<%# Eval(“AP_ALT”) %>’ border=”0″ /></a>
                </ItemTemplate>
                <HeaderStyle Font-Bold=”False” Font-Italic=”False” Font-Overline=”False” Font-Strikeout=”False” Font-Underline=”False” Wrap=”False” />
            </asp:DataList>
            <asp:SqlDataSource ID=”SqlDataSource3″ runat=”server” ConnectionString=”<%$ ConnectionStrings:WebDBConnectionString %>” SelectCommand=”SELECT * FROM [A_Press] WHERE (([IS_ACTIVE] = @IS_ACTIVE) AND ([AP_PAGE] = @AP_PAGE) AND (YEAR([AP_POSTDATE]) = @AP_POSTDATE))”>
                <SelectParameters>
                    <asp:Parameter DefaultValue=”1″ Name=”IS_ACTIVE” Type=”Int16″ />
                    <asp:Parameter DefaultValue=”0″ Name=”AP_PAGE” Type=”Int16″ />
                    <asp:QueryStringParameter DefaultValue=”2009″ Name=”AP_POSTDATE” QueryStringField=”year” />
                </SelectParameters>
            </asp:SqlDataSource>

六月 24, 2009 at 6:16 下午 Leave a comment

break sql statement

係一句sql statement , 係前面加 @ , 咁就可以直接click enter 分行~~

OleDbCommand cmd1 = new OleDbCommand(@”INSERT INTO [orders] (customer_name, customer_address, customer_suburb,
customer_postcode, customer_state, card_type, card_number, card_expire, order_total, order_date) VALUES (‘@name’, ‘@address’, ‘@suburb’, @code, ‘@state’,
‘@type’, @number, ‘@expire’, @total, ‘@date’)”, conn1);

五月 27, 2009 at 12:55 下午 Leave a comment

Older Posts


Recent Posts


Follow

Get every new post delivered to your Inbox.