DotNet Solution

  • Home
  • Asp.net
    • Controls
    • DataControl
    • Ajax
  • Web Design
    • Html
    • Css
    • Java Script
  • Sql
    • Queries
    • Function
    • Stored Procedures
  • MVC
    • OverView
    • Create First Application
  • BootStrap
    • Collapse Function

Wednesday, 20 July 2016

Numeric Value Validation Through JavaScript

  Unknown       06:15       Js       No comments    

Validate Only Numeric Value Enter In TextBox Using JavaScript function
Firstly Write Java Script Function in <head tag> in Asp.Net
After That Call Function <OnKeyPress > on TextBox
Ex.
<head>
<script type="text/javascript">
   var specialKeys = new Array();
   specialKeys.push(8); //Backspace
        function IsNumeric(e)
         {
                  var keyCode = e.which ? e.which : e.keyCode
                   var ret = ((keyCode >= 48 && keyCode <= 57) || specialKeys.indexOf(keyCode) != -1);
                   document.getElementById("error").style.display = ret ? "none" : "inline";
                    return ret;
          }
</script>
</head>

Call On TextBox
ex.
<table>
<tr>
<td> Employee Salary<td>
<td>:</td>
<td>
  <asp:TextBox ID="tbnEmpSalary" runat="server" MaxLength="12" onkeypress="return IsNumeric(event)"></asp:TextBox>
     <span id="error">* Input digits (0 - 9)</span>
</td>
</tr>
</table>

OutPut
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Saturday, 16 July 2016

Split Function in Sql Serever

  Unknown       03:31       No comments    

We Use This Function and Get Values .Values split With Comma Operator and Get Split Values

Ex.
CREATE function [dbo].[SplitPra]       
(       
 @list varchar(8000)       
)       
returns @t table        
(       
 Word varchar(MAX) not null,       
 Position int identity(1,1) not null       
)       
as begin       
  declare        
    @pos int,       
    @lpos int,       
    @item varchar(100),       
    @ignore varchar(100),       
    @dl int,       
    @a1 int,       
    @a2 int,       
    @z1 int,       
    @z2 int,       
    @n1 int,       
    @n2 int,       
 @n3 int,      
 @n4 int,     
 @n5 int,      
    @c varchar(1),       
    @a smallint       
  select        
    @a1 = ascii('a'),       
    @a2 = ascii('A'),       
    @z1 = ascii('z'),       
    @z2 = ascii('Z'),       
    @n1 = ascii('0'),       
    @n2 = ascii('9'),       
 @n3 = ascii('.'),     
 @n4 = ascii('-'),     
 @n5 = ascii(' ')     
  set @ignore = '''"'       
  set @pos = 1       
  set @dl = datalength(@list)       
  set @lpos = 1       
  set @item = ''       
  while (@pos <= @dl) begin       
    set @c = substring(@list, @pos, 1)       
    if (@ignore not like '%' + @c + '%') begin       
      set @a = ascii(@c)       
      if ((@a >= @a1) and (@a <= @z1))         
        or ((@a >= @a2) and (@a <= @z2))       
        or ((@a >= @n1) and (@a <= @n2))       
  or (@a=@n3) or (@a=@n4) or (@a=@n5)      
      begin       
        set @item = @item + @c       
      end else if (@item > '') begin       
        insert into @t values (@item)       
        set @item = ''       
      end       
    end        
    set @pos = @pos + 1       
  end       
  if (@item > '') begin       
    insert into @t values (@item)       
  end       
  return       
end


Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Values Enter With SplitFunction in Sql Server

  Unknown       03:28       StoredProcedures       No comments    


Basically We Use Split Function Thorugh Commma Sepertaed string value with  Comma  Means One Then more value through split function Enter and Fatch Single Values in A new Record

Ex.
Create procedure CommaSeperate                    
@st1 nvarchar(max),
str2 nvarchar(max)                 
AS                             
DECLARE    @i INT,@totaltran INT ,@st11 NVARCHAR(50),@str22 NVARCHAR(50)                   
SELECT @totaltran=dbo.fnCountOccurences(',',@str22)                             
SET @i=1                             
WHILE @i<=@totaltran                           
 BEGIN                
   SELECT @st11=a.Word,@str22=b.Word  FROM dbo.splitpra(@st1) a, dbo.splitpra(@str2)                           
nbsp;  WHERE a.position=@i AND b.position=@i                       
   SET @i=@i+1                        
   Execute Query And PRocedure                       
  
 END  
 SELECT @totaltran 

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Count Number Of Word In Sql Server

  Unknown       03:15       Function       No comments    

We Count HowMany Words Present in This String Through Function in Sql Server
Then Use This Code


CREATE FUNCTION fnCountOccurences     
               (@ShortString VARCHAR(100),     
                @LongString  VARCHAR(8000))     
RETURNS INT     
AS     
  BEGIN     
    DECLARE  @Text      VARCHAR(8000),     
             @Frequency INT     
         
    SET @Text = @LongString     
         
    SET @Text = REPLACE(@Text,@ShortString,'')     
         
    SET @Frequency = (len(rtrim(@LongString)) - len(rtrim(@Text)))     
                    / len(rtrim(@ShortString))     
         
    RETURN (@Frequency)     
  END

We Get OutPut:-

 SELECT[dbo].[fnCountOccurences](',','a,b,c,c,')
Execute
OutPut- 4
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Friday, 15 July 2016

Reset Identity Column in Sql Server

  Unknown       02:11       Queries       1 comment    

We Want To Reset Identity Column Then Use Code.If We Delete column By Id Like We delete 5 no id and
After Than we Insert New then We get 6 no Id .We Show Data 1 to 4 id then 6 because 5 no id We Deleted Then Use Code and Get 5 id In Example-
Example-
SELECT * FROM vibha1<Table Name> --Here Vibha1 is TableName
We get Values-











Delete data  from table
Ex.
DELETE FROM vibha1 WHERE id=6
One Value Delete then Insert Value
INSERT INTO vibha1(name) VALUES('vibha1')

Get Values-










Then We Use Code
Syntax: DBCC CHECKIDENT( <TableName>, RESEED, <ValuesThen Start>)
And Delete id 7 record
DELETE FROM vibha1 WHERE id=7
Then  Execute This
 DBCC CHECKIDENT( vibha1 , RESEED, 5)
Then Insert
INSERT INTO vibha1(name) VALUES('vibha1')
Now Get Result

Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Saturday, 9 July 2016

Asp.net- MultiView

  Unknown       00:26       Controls       1 comment    

MultiView and View controls allow you to divide the content of a page into different groups, displaying only one group at a time. Each View control manages one group of content and all the View controls are held together in a MultiView control.
The MultiView control is responsible for displaying one View control at a time. The View displayed is called the active view.

The syntax of MultiView control is:
<asp:MultView ID= "MultiView1" runat= "server">
</asp:MultiView>
 
The syntax of View control is:
 <asp:View ID= "View1" runat= "server">
</asp:View> 

However, the View control cannot exist on its own. It would render error
 if you try to use it stand-alone. It is always used with a Multiview 
control as:
<asp:MultView ID= "MultiView1" runat= "server">
   <asp:View ID= "View1" runat= "server"> </asp:View>
</asp:MultiView> 
 
Properties
ActiveViewIndex- A zero based index that denotes the active view. If no view is active, then the index is -1.

Example-
 Aspx Source Code-
<table border="0" cellpadding="2" cellspacing="3" width="100%">
<tr>
<td>
<asp:LinkButton ID="lnkTab1" runat="server" OnClick="lnkTab1_Click">Tab1</asp:LinkButton></td>
<td>
<asp:LinkButton ID="lnkTab2" runat="server" OnClick="lnkTab2_Click">Tab2</asp:LinkButton></td>
<td>
<asp:LinkButton ID="lnkTab3" runat="server" OnClick="lnkTab3_Click">Tab3</asp:LinkButton></td>
</tr>
<tr>
<td colspan="3">
<asp:MultiView ID="MultiView1" runat="server">
<table width="100%" cellpadding="2" cellspacing="5">
<tr>
<td>
<asp:View ID="View1" runat="server">
Content 1 goes here</asp:View>
</td>
<td>
<asp:View ID="View2" runat="server">
Content 2 goes here</asp:View>
</td>
<td>
<asp:View ID="View3" runat="server">
content 3 goes here</asp:View>
</td>
</tr>
</table>
</asp:MultiView></td>
</tr>
</table

C# Code
protected void Page_Load(object sender, EventArgs e)
{
  if (!IsPostBack)
   {
   SetDefaultView();
   }
}
private void SetDefaultView()
{
MultiView1.ActiveViewIndex = 0;
}
protected void lnkTab1_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 0;
}
protected void lnkTab2_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 1;
}
protected void lnkTab3_Click(object sender, EventArgs e)
{
MultiView1.ActiveViewIndex = 2;
}

OutPut-







Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+

Saturday, 25 June 2016

Table Structure Acces in Database

  Unknown       01:10       StoredProcedures       No comments    

Table Structure Get From  Database in Sql Server

If We Want To get Any  Table Structure from Database .
Show How Many Column Created and Datatype also Then Use This Code

Create Procedure in Sql Server

CREATE Procedure dbo.Gettable     
@tablename nvarchar(100)   
as     
    DECLARE    
           @object_name SYSNAME  ,      
          @object_id INT       
        , @SQL NVARCHAR(MAX)       
           
    SELECT       
          @object_name = '[' + OBJECT_SCHEMA_NAME(o.[object_id]) + '].[' + OBJECT_NAME([object_id]) + ']'       
        , @object_id = [object_id]       
    FROM (SELECT [object_id] = OBJECT_ID(@tablename, 'U')) o       
           
    SELECT @SQL = 'CREATE TABLE ' + @object_name + CHAR(13) + '(' + CHAR(13) + STUFF((       
        SELECT CHAR(13) + '    , [' + c.name + '] ' +        
            CASE WHEN c.is_computed = 1       
                THEN 'AS ' + OBJECT_DEFINITION(c.[object_id], c.column_id)       
                ELSE        
                    CASE WHEN c.system_type_id != c.user_type_id        
                        THEN '[' + SCHEMA_NAME(tp.[schema_id]) + '].[' + tp.name + ']'        
                        ELSE '[' + UPPER(tp.name) + ']'        
                    END  +        
                    CASE        
                        WHEN tp.name IN ('varchar', 'char', 'varbinary', 'binary')       
                            THEN '(' + CASE WHEN c.max_length = -1        
                                            THEN 'MAX'        
                                            ELSE CAST(c.max_length AS VARCHAR(5))        
                                        END + ')'       
                        WHEN tp.name IN ('nvarchar', 'nchar')       
                            THEN '(' + CASE WHEN c.max_length = -1        
                                            THEN 'MAX'        
                                            ELSE CAST(c.max_length / 2 AS VARCHAR(5))        
                                        END + ')'       
                        WHEN tp.name IN ('datetime2', 'time2', 'datetimeoffset')        
                            THEN '(' + CAST(c.scale AS VARCHAR(5)) + ')'       
                        WHEN tp.name = 'decimal'       
                            THEN '(' + CAST(c.[precision] AS VARCHAR(5)) + ',' + CAST(c.scale AS VARCHAR(5)) + ')'       
                        ELSE ''       
                    END +       
                    CASE WHEN c.collation_name IS NOT NULL AND c.system_type_id = c.user_type_id        
                        THEN ' COLLATE ' + c.collation_name       
                        ELSE ''       
                    END +       
                    CASE WHEN c.is_nullable = 1        
                        THEN ' NULL'       
                        ELSE ' NOT NULL'       
                    END +       
                    CASE WHEN c.default_object_id != 0        
                        THEN ' CONSTRAINT [' + OBJECT_NAME(c.default_object_id) + ']' +        
                             ' DEFAULT ' + OBJECT_DEFINITION(c.default_object_id)       
                        ELSE ''       
                    END +        
                    CASE WHEN cc.[object_id] IS NOT NULL        
                        THEN ' CONSTRAINT [' + cc.name + '] CHECK ' + cc.[definition]       
                        ELSE ''       
                    END +       
                    CASE WHEN c.is_identity = 1        
                        THEN ' IDENTITY(' + CAST(IDENTITYPROPERTY(c.[object_id], 'SeedValue') AS VARCHAR(5)) + ',' +        
                                        CAST(IDENTITYPROPERTY(c.[object_id], 'IncrementValue') AS VARCHAR(5)) + ')'        
                        ELSE ''        
                    END        
            END       
        FROM sys.columns c WITH(NOLOCK)       
        JOIN sys.types tp WITH(NOLOCK) ON c.user_type_id = tp.user_type_id       
        LEFT JOIN sys.check_constraints cc WITH(NOLOCK)        
             ON c.[object_id] = cc.parent_object_id        
            AND cc.parent_column_id = c.column_id       
        WHERE c.[object_id] = @object_id       
        ORDER BY c.column_id       
     FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 7, '      ') +        
        ISNULL((SELECT '       
        , CONSTRAINT [' + i.name + '] PRIMARY KEY ' +        
        CASE WHEN i.index_id = 1        
            THEN 'CLUSTERED'        
            ELSE 'NONCLUSTERED'        
        END +' (' + (       
        SELECT STUFF(CAST((       
            SELECT ', [' + COL_NAME(ic.[object_id], ic.column_id) + ']' +       
                    CASE WHEN ic.is_descending_key = 1       
                        THEN ' DESC'       
                        ELSE ''       
                    END       
            FROM sys.index_columns ic WITH(NOLOCK)       
            WHERE i.[object_id] = ic.[object_id]       
                AND i.index_id = ic.index_id       
            FOR XML PATH(N''), TYPE) AS NVARCHAR(MAX)), 1, 2, '')) + ')'       
        FROM sys.indexes i WITH(NOLOCK)       
        WHERE i.[object_id] = @object_id       
            AND i.is_primary_key = 1), '') + CHAR(13) + ');'       
           
    PRINT @SQL


Use This Code We Show table Structure like

SELECT * FROM tbl_Acc_Type
After Execution We get Table
 
ID    AccType
1    Payment
2    Receipt

We Use table Structure Then Use this Procedure To Directaly Show Structure
Syntax-  GetTable  TableName
Ex.-   GetTable tbl_Acc_Type

After Execution We get Table Structure

CREATE TABLE [dbo].[tbl_Acc_Type]
(
      [ID] [INT] NOT NULL IDENTITY(1,1)
    , [AccType] [NVARCHAR](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL     
        , CONSTRAINT [PK_tbl_Acc_Type] PRIMARY KEY CLUSTERED ([ID])
);


We Will Create This Table in Other Database and use Structure Also


 
Read More
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
Newer Posts Older Posts Home

Popular Posts

  • Numeric Value Validation Through JavaScript
    Validate Only Numeric Value Enter In TextBox Using JavaScript function Firstly Write Java Script Function in <head tag> in Asp.Net ...
  • Auto Increment Id in Sql Server
    SQL server identity column values use in table Steps- Firstly Open-> Sql Server Create Table -> First Field Like ID Usually Autoi...
  • Asp.net- MultiView
    MultiView and View controls allow you to divide the content of a page into different groups, displaying only one group at a time. Each Vie...
  • Reset Identity Column in Sql Server
    We Want To Reset Identity Column Then Use Code.If We Delete column By Id Like We delete 5 no id and After Than we Insert New then We get 6...
  • Email Validation In JavaScript
    We use Validation for Email  in Javascript like in above example <!DOCTYPE html> <html> <head> <script> fu...
  • Javascript Regular Expression Email Validate
    Validate Email using Regular Expression In JavaScript- 1. Create Input type Text box and and onclick cal  checkemail function of Javascr...
  • Count Number Of Word In Sql Server
    We Count HowMany Words Present in This String Through Function in Sql Server Then Use This Code CREATE FUNCTION fnCountOccurences     ...
  • Collapse Function Use in Bootstrap.
    Defination  1.  Collapse Means suddenly fall down. 2.  Just add data-toggle="collapse" and a data-target to element to ...
  • Table Structure Acces in Database
    Table Structure Get From  Database in Sql Server If We Want To get Any  Table Structure from Database . Show How Many Column Created and...
  • Open First Application in MVC
    How To Create First Application in MVC.Follows Some Steps-    STEP 1 . Firstly Go Start menu in Computer And Click on Installed Visual s...

Blog Archive

  • ►  2016 ( 36 )
    • ►  February ( 1 )
    • ►  March ( 5 )
    • ►  April ( 1 )
    • ►  June ( 10 )
    • ►  July ( 6 )
    • ►  November ( 8 )
    • ►  December ( 5 )
  • ▼  2017 ( 1 )
    • ▼  January ( 1 )
      • Whats is Jquery
Powered by Blogger.

Categories

  • Ajax
  • AllFunction
  • Controls
  • CreateApplication
  • css
  • Function
  • javascript
  • Js
  • over view
  • OverView
  • Queries
  • StoredProcedures

Text Widget

Sample Text

Pages

  • Home

Copyright © DotNet Solution | Powered by Blogger
Design by Vibha Acharya