مشاهده حجم یک جدول

sp_spaceused [نام جدول]

sp_spaceused tblkala

تغییر Data Type در SQL Server

ALTER TABLE table_name

ALTER COLUMN column_name datatype

اضافه کردن User Control هنگام اجرای برنامه

Dim myUserControl As Control = Page.LoadControl("userControl.ascx")

Panel1.Controls.Add(myUserControl)


اگر user control دارای خصوصیت custome ی باشد به صورت زیر مقداردهی میشود:


Dim myUC As step1View = CType(Page.LoadControl("/control/step/step1View.ascx"), step1View)
myUC.sort = 5

Panel1.Controls.Add(myUC)

Setting up Web.config to allow uploading of large files by ASP .NET applications

Introduction

During the construction of an intranet application that allows users to upload documents and share information between users, I noticed that when a user tries to upload files that are larger than 4 MB, he is asked for the user/password and even if he enters the correct user/password, the file is not uploaded, and he gets a HTTP 401.1 error.

Of course, this should not be an article, but CodeProject doesn't have a "quick tip section"-like, so here it goes.

The problem

By default, Machine.config is configured to accept HTTP Requests upto 4096 KB (4 MB) and it is reflected in all your ASP.NET applications. You can change the Machine.config file directly, or you can change only the Web.config file of the application(s) you want to.

The solution

Open your Web.config file, and just below the <system.web> tag, add the following tag:

<httpRuntime 
executionTimeout="90" 
maxRequestLength="4096" 
useFullyQualifiedRedirectUrl="false" 
minFreeThreads="8" 
minLocalRequestFreeThreads="4" 
appRequestQueueLimit="100" 
enableVersionHeader="true"
/>

Now, just take a look at the maxRequestLength="4096" attribute of the <httpRuntime> tag. As you may have realized, all you need to do is change the value to some other value of your choice (8192 for 8 Mb, 16384 for 16 Mb, 65536 for 64 Mb, and so on...).

That's it. I hope it is useful to you.

جلوگیری از Copy اطلاعات نوشتاری در HTML

فقط کافیه کد زیر رو به صفحه HTML اضافه کنید:


<body onselectstart="return false;"  oncontextmenu="return false;">


برای جلوگیری از انتخاب متن توسط دکمه Ctrl +A باید کد زیر رو به فایل CSS خودتون اضافه کنید:


body{
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

Paging a Query with SQL Server

DECLARE @PageNumber AS INT, @RowspPage AS INT

SET @PageNumber = 6

SET @RowspPage = 5

SELECT * FROM (

             SELECT ROW_NUMBER() OVER(ORDER BY id) AS NUMBER,

                    * FROM tableType

               ) AS TBL

WHERE NUMBER BETWEEN ((@PageNumber - 1) * @RowspPage + 1) AND (@PageNumber * @RowspPage)

ORDER BY id

ستون جدید در جدول با استفاده از T-Sql

ALTER TABLE table_name

ADD column_name datatype default(DEFAULT_VALUE)


برای اضافه کردن چند ستون آنها را با ویرگول از یکدیگر جدا میکنیم

ALTER TABLE table_name

ADD column_name1 datatype default(DEFAULT_VALUE),

column_name2 datatype default(DEFAULT_VALUE),

column_name3 datatype default(DEFAULT_VALUE),

انتخاب عدد تصادفی بین دو عدد مشخص

RND * ( max - min ) + min
مثال: یافتن عدد تصادفی بین ۱ و ۱۰
RND * (10-1) + 1

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