Split String

CREATE FUNCTION dbo.Split
(
    @String NVARCHAR(max),
    @Delimiter VARCHAR(5)
)
RETURNS @SplittedValues TABLE
(
    id SMALLINT IDENTITY(1,1),
    item VARCHAR(200)
)
AS
BEGIN
    DECLARE @SplitLength INT
    WHILE LEN(@String) > 0
    BEGIN
        SELECT @SplitLength = (CASE CHARINDEX(@Delimiter,@String) WHEN 0 THEN
            LEN(@String) ELSE CHARINDEX(@Delimiter,@String) -1 END)
        INSERT INTO @SplittedValues
            SELECT SUBSTRING(@String,1,@SplitLength)
                SELECT @String = (CASE (LEN(@String) - @SplitLength) WHEN 0 THEN ''
                    ELSE RIGHT(@String, LEN(@String) - @SplitLength - 1) END)
    END
    RETURN
END

ویرایش فیلد پایگاه داده مقدار پیش فرض

How to set a default value for an existing column


ALTER TABLE dailyView ADD DEFAULT getdate() FOR st

Scroll To Element

    <script>

        $(document).ready(function (){

            $("#click").click(function (){

                //$(this).animate(function(){

                    $('html, body').animate({

                        scrollTop: $("#div1").offset().top

                    }, 2000);

                //});

            });

        });

    </script>

ایجاد منوی داینامیک و خواندن آن از پایگاه داده

Function createMenu() As String

        Dim ds As New DataSet()

        Dim cn As New SqlConnection(DB.connectionStirng.ConnectionString())

        Dim cmd As New SqlCommand("SELECT * FROM content order by sort asc", cn)

        Dim da As New SqlDataAdapter(cmd)

        da.Fill(ds)

        Dim table As DataTable = ds.Tables(0)

        Dim parentMenus As DataRow() = table.Select("[parent]=1")

 

        Dim sb = New StringBuilder()

        Dim unorderedList As String = GenerateUL(parentMenus, table, sb)

        Return (unorderedList)

    End Function

 

    Private Function GenerateUL(ByVal menu As DataRow(), ByVal table As DataTable, ByVal sb As StringBuilder) As String

        sb.AppendLine("<ul>")

 

        If menu.Length > 0 Then

            For Each dr As DataRow In menu

                Dim menuText As String = dr("title").ToString()

                Dim line As String = [String].Format("<li><a href=#>{0}</a>", menuText)

                sb.AppendLine(line)

 

                Dim pid As String = dr("id").ToString()

 

                Dim subMenu As DataRow() = table.Select("[parent]=" & pid)

                If subMenu.Length > 0 Then

                    Dim subMenuBuilder = New StringBuilder()

                    sb.AppendLine(GenerateUL(subMenu, table, subMenuBuilder))

                End If

                sb.AppendLine("</li>")

            Next

        End If

 

        sb.Append("</ul>")

        Return sb.ToString()

    End Function

 

ارسال ایمیل با استفاده از Yahoo!, GMail, Hotmail

Server Parameters

Server NameSMTP AddressPortSSL
Yahoo!smtp.mail.yahoo.com587Yes
GMailsmtp.gmail.com587Yes
Hotmailsmtp.live.com587Yes

Sample Code

using System.Net;
using System.Net.Mail;

string smtpAddress = "smtp.mail.yahoo.com";
int portNumber = 587;
bool enableSSL = true;

string emailFrom = "email@yahoo.com";
string password = "abcdefg";
string emailTo = "someone@domain.com";
string subject = "Hello";
string body = "Hello, I'm just writing this to say Hi!";

using (MailMessage mail = new MailMessage())
mail.From = new MailAddress(emailFrom);
{
mail.To.Add(emailTo);
mail.Subject = subject;
mail.Body = body;
mail.IsBodyHtml = true;
// Can set to false, if you are sending pure text.

mail.Attachments.Add(new Attachment("C:\\SomeFile.txt"));
mail.Attachments.Add(new Attachment("C:\\SomeZip.zip"));

using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber))
{
smtp.Credentials = new NetworkCredential(emailFrom, password);
smtp.EnableSsl = enableSSL;
}
smtp.Send(mail);
}
منبع:

جستجوی صفحه به صفحه در پایگاه داده

select ID, title from software where ID IN(

   select top 10 ID from software where ID IN(

      select top 10 ID from software order by ID)

   order by id desc)

order by id

**********************************************************

select top 10 * from software where id in(

    select top 10 id from software where id IN(

        select top 70 id from software order by id desc)

    order by id asc)

order by id desc

حذف جدول

DROP TABLE table_name

استفاده از طیف رنگ در CSS

#grad {
  background: -webkit-linear-gradient(red, blue); /* For Safari 5.1 to 6.0 */
  background: -o-linear-gradient(red, blue); /* For Opera 11.1 to 12.0 */
  background: -moz-linear-gradient(red, blue); /* For Firefox 3.6 to 15 */
  background: linear-gradient(red, blue); /* Standard syntax */
}

منبع:

http://www.w3schools.com/css/css3_gradients.asp