SQL Server Data Types

by Kareem Allam 4. November 2011 19:00

Data Type

Size

Range

TINYINT(n)

1 byte

0 to 255 (unsigned)

SMALLINT(n)

2 bytes

-32,768 to 32,767

INT(n)

4 bytes

Approximately plus or minus 2 billion (-2,147,483,648 to 2,147,483,647)

BIGINT(n)

8 bytes

Approximately plus or minus 10 billion billion or 10 million trillion or 10 thousand quadrillion or 10 quintillion (-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807)

FLOAT(n)

4 bytes if n < 25 or 8 bytes if 24 < n < 54

n decimal places

REAL

4 bytes

 

DECIMAL(n,d)

5 to 17 bytes

n digits before and after the decimal point, d decimal places

SMALLMONEY

4 bytes

-214,748.3648 to 214,748.3647

MONEY

8 bytes

-922,337,203,685,477.5808 to 922,337,203,685,477.5807

SMALLDATETIME

4 bytes

01/01/1900 00:00 to 06/06/2079 23:59

DATETIME

8 bytes

01/01/1753 to 31/12/9999

DATETIME2

6 to 8 bytes

01/01/0001 to 31/12/9999. Intended as a replacement for SMALLDATETIME and DATETIME

DATETIMEOFFSET

8 to 10 bytes

01/01/0001 to 31/12/9999, includes space for timezone offset

DATE

3 bytes

01/01/0001 to 31/12/9999

TIME

3 to 5 bytes

Accurate to 100 nanoseconds

CHAR(n)

fixed length, 1 byte per character (n), up to 8000

Consumes n bytes of storage

NCHAR(n)

2 bytes per field length (n)

Stores unicode characters

VARCHAR(n)

variable length, 1 byte per character (n), up to 8000

Consumes 1 byte per character stored, up to n bytes

VARCHAR(MAX)

2 bytes per character stored

Maximum 2GB. Replacement for TEXT datatype

NVARCHAR(n)

2 bytes per character stored (n), up to 4000

Stores unicode characters

NVARCHAR(MAX)

2 byte per character stored

Maximum 2GB. Replacement for NTEXT datatype

BIT

1 bit

Null, 0 or 1

BINARY

Fixed width binary data

Up to 8000 bytes

VARBINARY

Variable width binary data

Up to 8000 bytes

VARBINARY(MAX)

Variable width binary data

Up to 2GB

XML

Stores XML documents

XML Schema collection can be defined to verify documents

If you enjoyed this post, make sure you subscribe to my RSS feed!

How To Embed Any Media Player in GridView Control

by Kareem Allam 3. August 2011 06:01

This example shows how to use any media player in  GridView Control and Get movie file  path  (server Pathe or obtain videos from YouTube )  from MS SQL Database

 

MS SQL Database Table Structure

 

 

MS SQL Database Table Data

 

 

HTML Side

In your Page you Must insert in   GridView Control and SQL DataSource

 

<asp:SqlDataSource 
    ID="SqlDataSource1"
    runat="server"
    ConnectionString="<%$ ConnectionStrings:XConStr %>"
    SelectCommand="SELECT ID, Name, FilePath, Youtube FROM media">
</asp:SqlDataSource>

 

 

<asp:GridView
	ID="GridView1"
	runat="server"
	AutoGenerateColumns="False"
	DataKeyNames="ID"
	DataSourceID="SqlDataSource1" >

   <Columns>
 
     <asp:BoundField
	DataField="ID"
	HeaderText="ID"
	ReadOnly="True"
	SortExpression="ID" />
 
     <asp:BoundField
	DataField="Name"
	HeaderText="Name"
	SortExpression="Name" />
 
     <asp:BoundField
	DataField="FilePath"
	HeaderText="FilePath"
	SortExpression="FilePath" />
 
     <asp:CheckBoxField
	DataField="Youtube"
	HeaderText="Youtube"
	SortExpression="Youtube" />
 
  </Columns>
</asp:GridView>

 

 

THat Is the simply basic design for controls

NOW , I waill start to insert the Players

1 – Convert FilePath Field in GridView To Template Field

 

2 – Insert 2 Invisible Panels to template filed

       ( 1 For Media Palyer & The second for Youtube )

 

<asp:TemplateField HeaderText="FilePath" SortExpression="FilePath">
    <ItemTemplate>
        <asp:Panel ID="Panel_MediaPlayer" runat="server" Visible="false">
             <object width="200" height="200"
                  classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
                  id="MPPlayer">
             <param name="Filename" value='<%# Eval("Name") %>'>
             <param name="AutoStart" value="False">
             <param name="ShowControls" value="True">
             <param name="ShowStatusBar" value="True">
             <param name="ShowDisplay" value="False">
             <param name="AutoRewind" value="True">
                  <embed
                      type="application/x-mplayer2"
                      pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/MediaPlayer/"
                      width="200" height="200" src='<%# Eval("FilePath") %>'
                      filename='<%# Eval("Name") %>' autostart="False"
                      showcontrols="True" showstatusbar="False"
                      showdisplay="False" autorewind="True">
                  </embed>
             </object>
        </asp:Panel>
                              

        <asp:Panel ID="Panel_Youtube" runat="server" Visible="false">
             <object width="200" height="200" >
             <param name='<%# Eval("Name") %>' value='<%# Eval("FilePath") %>' />
             <param name="allowFullScreen" value="true"/>
             <param name="allowscriptaccess" value="always"/>
                  <embed src='<%# Eval("FilePath") %>'
                      type="application/x-shockwave-flash"
                      allowscriptaccess="always"
                      allowfullscreen="true"
                      width="200" height="200"
                      pluginspage="http://www.adobe.com/go/getflashplayer">
                  </embed>
             </object>
        </asp:Panel>
                                
   </ItemTemplate>
</asp:TemplateField>

 


 

Code Side

 

Protected Sub GridView1_RowDataBound _
       (ByVal sender As Object, _
        ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) _
        Handles GridView1.RowDataBound
 
        Dim XPanel_MediaPlayer As New Panel
        Dim XCPanel_Youtube As New Panel
 
        If e.Row.RowType = DataControlRowType.DataRow Then
            XPanel_MediaPlayer = e.Row.FindControl("Panel_MediaPlayer")
            XCPanel_Youtube = e.Row.FindControl("Panel_Youtube")
 
            XPanel_MediaPlayer.Visible = False
            XCPanel_Youtube.Visible = False
 
            If Val(Convert.ToInt32(DataBinder.Eval(e.Row.DataItem, "Youtube"))) = 1 Then
                XCPanel_Youtube.Visible = True
            Else
                XPanel_MediaPlayer.Visible = True
            End If
 
        End If
 
    End Sub

 

 

 

 PS

You can Use any player , just insert the appropriate Object

 

Player 

File Formats 

Flash 

flv, mp3, swf

Windows Media Player 

asx, asf, avi, wma, wmv

QuickTime 

aif,aiff,aac,au,bmp,gsm,mov,mid,

midi,mpg,mpeg,mp4,m4a,psd,qt,qtif,

qif,qti,snd,tif,tiff,wav,3g2,3pg

Real Player 

ra, ram, rm, rpm, rv, smi, smil

 

 

 

Audio File

<object codebase="http://www.apple.com/qtactivex/qtplugin.cab" 
        classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" 
        type="application/x-oleobject"> 
        <param name="url" value=" FileName.avi"> 
        <embed src="FileName.avi" 
            type="application/x-mplayer2" 
            pluginspage="http://www.microsoft.com/Windows/MediaPlayer/">
         </embed> 
</object>


 

 

QuickTime Movie

 

<object codebase="http://www.apple.com/qtactivex/qtplugin.cab" 
        classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"> 
        <param name="src" value=" FileName.mov"> 
        <embed src=" FileName.mov" 
            pluginspage="http://www.apple.com/quicktime/download/">
        </embed> 
</object>

 


Flash  Movie

<object codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7" 
        classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" 
        type="application/x-oleobject"> 
        <param name="src" value=" FileName.swf"> 
        <embed src=" FileName.swf" 
            type="application/x-shockwave-flash" 
            pluginspage="http://www.adobe.com/go/getflashplayer">
         </embed> 
</object>


If you enjoyed this post, make sure you subscribe to my RSS feed!

About EgDev.com

If you would like to find value services with excellent quality and cost effectiveness and with a focus on speed , Just Follow

 Egypt Development Freelance Team.

Month List

Page List