Books for asp.net

Tuesday, December 13, 2011

simple disable button onclick

 <script language="javascript" type="text/javascript">
function DisableButton(button,span) {
Page_ClientValidate();
if (Page_IsValid) {
button.style.display = 'none';
document.getElementById(span).style.display = 'inline';
}
}
</script>



<asp:Button ID="btnAdd" runat="server" Text="Add" CssClass="Button" OnClientClick="DisableButton(this,'spanAdd');" />
<span id="spanAdd" class="Infotext" style="display: none;">Please Wait...</span>

Wednesday, November 30, 2011

view all stored procedure

SELECT *
FROM sys.procedures order by name

Sunday, May 15, 2011

MSSQL filter record with IF Statement

Example to filter user records by name / email if both criteria have the value

DECLARE @Name varchar(20)
DECLARE @Email varchar(20)

SET @Name = 'user'
SET @Email = ''

select * from User
WHERE (@Name = '' OR userName = @Name)
AND (@Email = '' OR userEmail= @Email)

Thursday, May 5, 2011

Drop All objects in database

Use [dbname]

declare @n char(1)

set @n = char(10)

declare @stmt nvarchar(max)

-- procedures
select @stmt = isnull( @stmt + @n, '' ) +
'drop procedure [' + name + ']'
from sys.procedures

-- check constraints
select @stmt = isnull( @stmt + @n, '' ) +
'alter table [' + object_name( parent_object_id ) + '] drop constraint [' + name + ']'
from sys.check_constraints

-- functions
select @stmt = isnull( @stmt + @n, '' ) +
'drop function [' + name + ']'
from sys.objects
where type in ( 'FN', 'IF', 'TF' )

-- views
select @stmt = isnull( @stmt + @n, '' ) +
'drop view [' + name + ']'
from sys.views

-- foreign keys
select @stmt = isnull( @stmt + @n, '' ) +
'alter table [' + object_name( parent_object_id ) + '] drop constraint [' + name + ']'
from sys.foreign_keys

-- tables
select @stmt = isnull( @stmt + @n, '' ) +
'drop table [' + name + ']'
from sys.tables

-- user defined types
select @stmt = isnull( @stmt + @n, '' ) +
'drop type [' + name + ']'
from sys.types
where is_user_defined = 1

exec sp_executesql @stmt