How to find the Size of Database File and Log File

Hi Friends
               Here is the Sql Server Code which is used to find the size of DataBase and Log file.
CREATE PROCEDURE [dbo.GetSize]
 
AS
BEGIN
   
SELECT DB_NAME(database_id) AS DatabaseName,
Name AS Logical_Name,
Physical_Name, (size*8)/1024 SizeMB
FROM sys.master_files
WHERE DB_NAME(database_id) = 'Dbname'
 
END
 
Learn more »

DIfferance Difference among Int32.Parse(), Convert.ToInt32(), and Int32.TryParse()

Hi friend,
  Here i am going to explain the Difference among Int32.Parse(), Convert.ToInt32(), and Int32.TryParse() Methods , this article taken as reference from .Net Spider.

Int32.parse(string)
-------------------------
Int32.Parse (string s) method converts the string representation of a number to its 32-bit signed integer equivalent.
When s is null reference, it will throw ArgumentNullException.
If s is other than integer value, it will throw FormatException.
When s represents a number less than MinValue or greater than MaxValue, it will throw OverflowException.

Example:
------------------
string s1 = "1234";
string s2 = "1234.65";
string s3 = null;
string s4 = "123456789123456789123456789123456789123456789";

int result;
bool success;

result = Int32.Parse(s1); //-- 1234
result = Int32.Parse(s2); //-- FormatException
result = Int32.Parse(s3); //-- ArgumentNullException
result = Int32.Parse(s4); //-- OverflowException


Convert.ToInt32(string)
----------------------------------
Convert.ToInt32(string s) method converts the specified the string representation of 32-bit signed integer equivalent. This calls in turn Int32.Parse () method.
When s is null reference, it will return 0 rather than throw ArgumentNullException
If s is other than integer value, it will throw FormatException.
When s represents a number less than MinValue or greater than MaxValue, it will throw OverflowException

Example:
result = Convert.ToInt32(s1); //-- 1234
result = Convert.ToInt32(s2); //-- FormatException
result = Convert.ToInt32(s3); //-- 0
result = Convert.ToInt32(s4); //-- OverflowException


Int32.TryParse(string, out int)
---------------------------------------------
Int32.Parse(string, out int) method converts the specified the string representation of 32-bit signed integer equivalent to out variable, and returns true if it parsed successfully, false otherwise. This method is available in C# 2.0
When s is null reference, it will return 0 rather than throw ArgumentNullException.
If s is other than integer value, the out variable will have 0 rather than FormatException.
When s represents a number less than MinValue or greater than MaxValue, the out variable will have 0 rather than OverflowException.

Example:-
-------------
success = Int32.TryParse(s1, out result); //-- success => true; result => 1234
success = Int32.TryParse(s2, out result); //-- success => false; result => 0
success = Int32.TryParse(s3, out result); //-- success => false; result => 0
success = Int32.TryParse(s4, out result); //-- success => false; result => 0

Convert.ToInt32 is better than Int32.Parse, since it return 0 rather than exception. But, again according to the requirement this can be used. TryParse will be best since it handles exception itself always.
Learn more »

Predefined Functions in SqlServer

Hi friends
               here are the predefined function in SQL Server 2005 which helps you in your programming .

Mathematical Functions
Abs,Ceiling,Floor,Exp,round

Select abs(-55) -- output will be 55 Get absolute value
Select ceiling(55.3) -- output '56' get round the value
Select Floor(45.8) -- output '45' get round the value
Select Exp(0) -- get a exponential value of '0' that is 1
Select Round(225.245874,3) -- output 225.246000 round a value after the no.of digit.

Trignometric Functions
Sin,Cos,Tan,Log

Select Sin(0) -- get sin value of '0' that is 0
Select Cos(0) -- get cos value of '0' that is 1
Select Tan(0) -- get tan value of '0' that is 0

String Functions
Ascii,Char,Reverse,SubString,
Stuff,Replicate,Replace,Ltrim,Rtrim

Select Ascii('A') -- Output '65' get Ascii value of 'A'
Select Char(97) -- output 'a' get char value of 97
Select Reverse('REVERSE')-- output 'ESREVER' get the reverse value of string
Select Substring('Hello World',3,5) -- output 'llo w'
Select Stuff('world',2,5,'welcome') -- output 'wwelcomorlde' Here 2 --> Start Position 5 --> Replace Char Length
Select Replicate('hello ',3) -- output 'hello hello hello ' its repeat a Value 3 times Here 3 --> No.of Times
Select Replace('abcdefgh','de','xy')-- output 'abcxyfgh'
Select Ltrim(' hello ') -- output 'hello ' remove a space in front of the string
Select Rtrim(' hello ') -- output ' hello' remove a space in end of the string

Date Functions
GetDate,DateAdd,DateDiff,DatePart

Select GetDate()--Get Current Date
Select Dateadd(dd,2,getdate())--Add 2 days from Current Date
Select Datediff(dd,'1985-05-06','2005-06-09') --Get Date difference between those days
Select Datepart(dd,getdate()) --get a date only from currentdate

System Functions
Db_Id,Db_Name,IsDate,Isnumeric

Select db_id('master')-- Get order of that Database
Select db_name(4)--Get a 4th order of name in a database
Select isdate('02/31/2005') --Date is availabe or not Here output comes '0' or '1'
Select isnumeric(15s) --Value is numeric or not Here output comes '0' or '1'

Aggregate Functions
Count,Max,Min,Avg,Sum

Count() --> Get Total Count of Row
Max() --> Get a Maximum value of a Column
Min() --> Get a Minimum value of a Column
Avg() --> Get a Average value of a column
Sum() --> Get Total Value of a Column 

Hope this will helps you
 Regards
Rajesh 
Learn more »

Controlling Authorization permissions in Asp.Net Application in C#

hi Friend 
    i am here with article on Form Authentication and Authorization in Web config file .When we use the forms based Authentication in Asp.Net Application. Only the authenticated users can access pages in the application. Unauthenticated users are redirected to the specified login page provided by the loginURL tag. If the user login from that page then the user is redirected to page they wanted to go.

We use the location tag to define the rules in the Web.Config.
<configuration>
        <system.web>
               <authentication mode="Forms" >
                       <forms loginUrl="login.aspx" name=".aspFormAuth" 
protection="None" path="/" timeout="30" >
                       </forms>
               </authentication>
<!—We first deny any unauthorized user in the site. -->
               <authorization>
                       <deny users="?" /> 
               </authorization>
        </system.web>
<!—Now we allow all the user to Home.aspx page here any unauthenticated User can 
access this page   -->
               <location path="Home.aspx">
               <system.web>
               <authorization>
                       <allow users ="*" />
               </authorization>
               </system.web>
               </location>
<!—we can also give unauthenticated users permission on a given directory.  -->
               <location path="FolderName">
               <system.web>
               <authorization>
                       <allow users ="*" />
               </authorization>
               </system.web>
               </location>
</configuration>
 
-------------------------------------Code Behind-----------------------------------
 
here is the code behing that you can use Code behind on any event to set authentication  
 
 if (FormsAuthentication.Authenticate(txtUserName.Value, txtPassword.Value))
       {
          FormsAuthentication.RedirectFromLoginPage(txtUserName.Value, false);
       }
       else
       {
          lblMessage.Text ="Unauthenticate User";

          FormsAuthentication.SignOut();
      }
 
 
 Hope this artical help you in your application
 
Regards 
 Rajesh 

Learn more »

Customizing SectionGroups and Sections in Web.config in C#


Hi Friends,
 some time  we need to declare our own SectionGroups and Sections in web.config depending upon certain situations.  here i am explaining you how to access and use the Section values in your application.
Here, I have created two Sections under one SectionGroup.
Hope this article will help whenever you want to handle SectionGroups in your web.config.


<configuration>
<configSections>
 <sectionGroup name="SectionGroupName"> //Here we declare the name of the section group
   <section name="SectionName1" 
     type=="System.Configuration.NameValueSectionHandler,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowLocation="true" allowDefinition="Everywhere"/>//Section name 1
   <section name="Sectionname2" 
     type=="System.Configuration.NameValueSectionHandler,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowLocation="true" allowDefinition="Everywhere"/>//Section name 2
</sectionGroup>
</configSections>


------------------------Here is the Syntax of Section Group--------------------------------

<sectionGroup 
   name="section name"
   type="configuration section handler class, assembly file name, version, culture, public key token">
   <section />
/>

The following sections describe attributes
Attribute
Description
Name
Required String attribute.
Specifies the name of the configuration section or element that is associated with the configuration section handler that is specified by the typeattribute. This is the name of the group element as it appears in the section settings area


type
Required String attribute.
Specifies the name of the configuration section handler class that handles the processing of the configuration settings that are in the section or element that is specified in the name attribute. Use the following format:
type=" Fully qualified class name , assembly file name, version, culture, public key token"
The definition must match the assembly reference. For example, if the version number in the following code example does not match the assembly, an error occurs.
type="MyConfigSectionHandler.MyHandler,MyCustomConfigurationHandler,Version=1.0.0.0,Culture




---------------Assign the Value of Sections-----------------------
<configuration>

<SectionGroupName>
<SectionName1>
<add key="A1" value="AWCompany"/>
<add key="A2" value="AXCompany"/>
</SectionName1>
<SectionName2>
<add key="S1" value="AWCompany"/>
<add key="S2" value="AXCompany"/>
</SectionName2>
</SectionGroupName>
</configuration>


----------------Access the value on page------------------------


                System.Collections.Specialized.NameValueCollection collectionObj=
                  (System.Collections.Specialized.NameValueCollection)
                  System.Configuration.ConfigurationSettings.GetConfig("SectionGroupName/SectionName1"); 
                collectionObj.Get(0).ToString();//Here Get(0) is first index value of section
              




Hope this article will help you...


Regards 
Rajesh


Learn more »

New Dynamic Sites Launched in jaipur Must See this!!!!



www.pinkcityroyals.com
India's No. one online B2B Advertisement Portal on Jaipur, Complete Jaipur Business Directory

www.jaipurtourandtravels.com
Jaipur Tour and Travels Portal, Jaipur Tour and Travels, Jaipur Tour packages, Jaipur Travels, JAIPUR
Travel Guide, Jaipur tour operators, Rajasthan Tour India Tour Package

www.dreamssofttechnology.com
Jaipur Software Development, Jaipur Web Development, jaipur Web Hosting, Jaipur Domain Reg. , Jaipur Web graphics Design, Complete Online Internet marketing Solutions Jaipur.

Jaipur’s Best Academic Training Providers, Best Content with Best Experts, (Associated with Guwadiya Softwares and Trainings).

Learn more »