A blog about Microsoft Technology like ASP.NET,C#.NET,SQL Server, Ajax that majorly focus on code, tips ,tweaks and tricks.
Sunday, July 29, 2012
Thursday, July 26, 2012
Alter Encrypted Stored Procedure
How to Alter Encrypted Stored Procedure ?
Yesterday i wrote about how to write a Stored procedure in a encrypted manner. If Stored Procedure or User Defined Function are created WITH ENCRYPTION keyword then is not possible to decrypt it using SQL Server commands. It is always advised to save a copy of the script used to create the SP or UDF on other media source than SQL Server.
Yesterday i wrote about how to write a Stored procedure in a encrypted manner. If Stored Procedure or User Defined Function are created WITH ENCRYPTION keyword then is not possible to decrypt it using SQL Server commands. It is always advised to save a copy of the script used to create the SP or UDF on other media source than SQL Server.
Encrypted Stored Procedure
How to write a encrypted Stored Procedure?
Sometimes we need to write a stored procedure so that alternative user cannot see written text within Stored Procedure.
Even you may be ineffective to see the text of the encrypted Stored Procedure in SQL Server Activity Monitor moreover as by using Sp_helptext SpName methodology.
So what's the command to write encrypted stored procedure.
Let See
Sometimes we need to write a stored procedure so that alternative user cannot see written text within Stored Procedure.
Even you may be ineffective to see the text of the encrypted Stored Procedure in SQL Server Activity Monitor moreover as by using Sp_helptext SpName methodology.
So what's the command to write encrypted stored procedure.
Let See
Tuesday, July 24, 2012
What's New in ASP.NET 4.5 and Visual Web Developer 11 Developer Preview
This document lists options and enhancements that are being introduced in ASP.NET 4.5. It conjointly lists enhancements being created for internet development in Visual Studio (Visual internet Developer).
- ASP.NET Core Runtime and Framework
- Asynchronously Reading and Writing HTTP Requests and Responses.
- Enhancements to HttpRequest handling
- Asynchronously flushing a response
- Support for await and Task-Based Asynchronous Modules and Handlers
- Asynchronous HTTP modules
- Asynchronous HTTP handlers
- New ASP.NET Request Validation options
- Deferred ("lazy") request validation
- Support for unvalidated requests.
Monday, July 23, 2012
UNION VS UNION ALL
UNION VS UNION ALL
UNION
The UNION command is employed to pick connected info from 2 tables, very similar to the be a part of command. However, when using the UNION command all selected columns have to be compelled to be of constant knowledge kind. With UNION, solely distinct values are selected.
UNION ALL
The UNION ALL command is equal to the UNION command, except that UNION ALL selects all values.
The distinction between Union and Union all is that Union all won't eliminate duplicate rows, instead it simply pulls all rows from all tables fitting your question specifics and combines them into a table.
A UNION statement effectively will a pick DISTINCT on the results set. If you recognize that each one the records came back are distinctive from your union, use UNION ALL instead, it offers faster results.
UNION
The UNION command is employed to pick connected info from 2 tables, very similar to the be a part of command. However, when using the UNION command all selected columns have to be compelled to be of constant knowledge kind. With UNION, solely distinct values are selected.
UNION ALL
The UNION ALL command is equal to the UNION command, except that UNION ALL selects all values.
The distinction between Union and Union all is that Union all won't eliminate duplicate rows, instead it simply pulls all rows from all tables fitting your question specifics and combines them into a table.
A UNION statement effectively will a pick DISTINCT on the results set. If you recognize that each one the records came back are distinctive from your union, use UNION ALL instead, it offers faster results.
Sunday, July 22, 2012
Stored Procedure and Transactions
Stored Procedure and Transactions
I simply overheard the subsequent statement – “I don't use Transactions in SQL as i exploit Stored Procedure“.
I simply realized that there are numerous misconceptions regarding this subject. Transactions has nothing to try and do with Stored Procedures. Let me demonstrate that with a straightforward example.
USE tempdb
GO
-- produce three check Tables
CREATE TABLE TABLE_1 (ID INT);
CREATE TABLE TABLE_2 (ID INT);
CREATE TABLE TABLE_3 (ID INT);
GO
-- produce SP
CREATE PROCEDURE TestSP
AS
INSERT INTO TABLE_1 (ID)
VALUES (1)
INSERT INTO TABLE_2 (ID)
VALUES ('a')
INSERT INTO TABLE_3 (ID)
VALUES (3)
GO
-- Execute SP
-- SP can error out
EXEC TestSP
GO
-- Check the Values in Table
SELECT *
FROM TABLE_1;
SELECT *
FROM TABLE_2;
SELECT *
FROM TABLE_3;
GO
Now, the most purpose is: If Stored Procedure is transactional then, it ought to roll back complete transactions when it encounters any errors. Well, that doesn't happen during this case, that proves that Stored Procedure doesn't solely give simply the transactional feature to a batch of T-SQL.
I simply overheard the subsequent statement – “I don't use Transactions in SQL as i exploit Stored Procedure“.
I simply realized that there are numerous misconceptions regarding this subject. Transactions has nothing to try and do with Stored Procedures. Let me demonstrate that with a straightforward example.
USE tempdb
GO
-- produce three check Tables
CREATE TABLE TABLE_1 (ID INT);
CREATE TABLE TABLE_2 (ID INT);
CREATE TABLE TABLE_3 (ID INT);
GO
-- produce SP
CREATE PROCEDURE TestSP
AS
INSERT INTO TABLE_1 (ID)
VALUES (1)
INSERT INTO TABLE_2 (ID)
VALUES ('a')
INSERT INTO TABLE_3 (ID)
VALUES (3)
GO
-- Execute SP
-- SP can error out
EXEC TestSP
GO
-- Check the Values in Table
SELECT *
FROM TABLE_1;
SELECT *
FROM TABLE_2;
SELECT *
FROM TABLE_3;
GO
Now, the most purpose is: If Stored Procedure is transactional then, it ought to roll back complete transactions when it encounters any errors. Well, that doesn't happen during this case, that proves that Stored Procedure doesn't solely give simply the transactional feature to a batch of T-SQL.
Send Asynchronous Email in Asp.net
Send Asynchronous Email in Asp.net?
when you are sending bulk email using Asp.net then sending email using traditional parameter would be terribly time consuming as a result of we'll ought to expect the execution of smtp.send().but in Async methodology Email are going to be delivered in background and that we also can manage the output of email by Async handler.
Here i'm providing a code snippet to send email in Async manner.
using System.Web.Util;
static void SendAsyncEmail()
when you are sending bulk email using Asp.net then sending email using traditional parameter would be terribly time consuming as a result of we'll ought to expect the execution of smtp.send().but in Async methodology Email are going to be delivered in background and that we also can manage the output of email by Async handler.
Here i'm providing a code snippet to send email in Async manner.
using System.Web.Util;
static void SendAsyncEmail()
{ MailMessage cnetcode_mail = new MailMessage(); cnetcode_mail.From = new MailAddress("RD@cnetcode.com"); cnetcode_mail.To.Add("you@cnetcode.com"); cnetcode_mail.Subject = "your subject goes here"; cnetcode_mail.Body = "Body content of the email."; //send the message SmtpClient smtp = new SmtpClient("Outgoing SMTP IP"); //Enter mail server address object userState = cnetcode_mail; smtp.SendCompleted += new SendCompletedEventHandler(SmtpClient_OnCompleted)
smtp.SendAsync( cnetcode_mail, userState ); }
Thursday, July 19, 2012
Unable to connect to Sql Server
If you are unable to connect your SQL Server from outside or from Asp.net web.config
then you must check this setting.
open your Sql Server and right click on your connected server and go to properties.
click security from left hand side and ensure
Sql server and windows authentication mode is enable.
:))
then you must check this setting.
open your Sql Server and right click on your connected server and go to properties.
click security from left hand side and ensure
Sql server and windows authentication mode is enable.
:))
Tips to Speed up SQL Query
Almost Every website data is stored in a database and served to visitors
upon request. Databases are very fast, but there is lots of things that we need to enhance speed and make sure not to waste any server
resources. In this article, I am suggesting you 10 tips to
optimize and speed up your Sql query.
1. Do not Select column that we do not need.
A very common practice is to use Select * from tablename.
It's better to select column which you need in output.
2. Avoid using Cursor , use while loop instead of Cursor.
3. Avoid using Sql statement in a loop.It's takes a lot of resource.
4.Use Join instead of Subqueries.
1. Do not Select column that we do not need.
A very common practice is to use Select * from tablename.
It's better to select column which you need in output.
2. Avoid using Cursor , use while loop instead of Cursor.
3. Avoid using Sql statement in a loop.It's takes a lot of resource.
4.Use Join instead of Subqueries.
SELECT a.id, (SELECT MAX(created) FROM posts WHERE book_id = a.id) AS latest_post FROM books a
However subqueries are useful, they often can be replaced by a join, which is definitely faster to execute.
SELECT a.id, MAX(p.created) AS latest_post FROM books a INNER JOIN posts p ON (a.id = p.book_id) GROUP BY a.id
Enable IIS 7.0 Compression
To enable Compression at IIS 7.0
Enabling IIS Compression can improve performance of a web site.
you can enable both
A) Static Compression
B) Dynamic Compression
Follow these steps to enable it:-
Goto run and type intemgr => it will open up your IIS => then select your website from left hand side pane.
Now at right side you will see an option Compression just click it twice and here we go.
Check Static and dynamic compression.
[note: By default dynamic compression is disabled you need to enable dynamic compression from server manager in administrative panel]
:))
Enabling IIS Compression can improve performance of a web site.
you can enable both
A) Static Compression
B) Dynamic Compression
Follow these steps to enable it:-
Goto run and type intemgr => it will open up your IIS => then select your website from left hand side pane.
Now at right side you will see an option Compression just click it twice and here we go.
Check Static and dynamic compression.
[note: By default dynamic compression is disabled you need to enable dynamic compression from server manager in administrative panel]
:))
Speeding Up Your Web Site
To speed up website we need to take care about certain things.
i am providing several points which you should take care while developing and deploying your website.
Definately i will elaborate on these tips or you can Google around to find some useful info!!!
:))
i am providing several points which you should take care while developing and deploying your website.
1. Minimize HTTP request
2. Use a CDN for static file.
3. Add an Expire Header.
4. Gzip or compress site text. here is the link for Gzip Compression
5. Put CSS at top and script at the bottom.
6.minimize javascript.
7. Avoid duplicate Scripts.
8.Configure Etag.
9.Avoid Redirects.
10. Flush Buffer early
Definately i will elaborate on these tips or you can Google around to find some useful info!!!
:))
Favicon
What is Favicon ?
when you open up a browser and visit a site you will see an icon on the tab
this is called favicon.Every time when we request a page it search for favicon.
It is a best practice to use favicon in asp.net application.it also optimize performance of website a bit.
to use favicon just add this under <Head> tag
<link rel="shortcut icon" href="URL or path of your icon file"/>
Remember to replace URL or path of your icon file file with your icon file's url.
Enjoy programming...:))
when you open up a browser and visit a site you will see an icon on the tab
this is called favicon.Every time when we request a page it search for favicon.
It is a best practice to use favicon in asp.net application.it also optimize performance of website a bit.
to use favicon just add this under <Head> tag
<link rel="shortcut icon" href="URL or path of your icon file"/>
Remember to replace URL or path of your icon file file with your icon file's url.
Enjoy programming...:))
Wednesday, July 18, 2012
Visual Studio Build error
If you are facing problem to build your visual studio Application even if there was no syntax error then don't worry you just need to delete some temporary files.
Delete cache file of your project if problem in building.
%LocalAppData%\Microsoft\WebsiteCache
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files
:)
Delete cache file of your project if problem in building.
%LocalAppData%\Microsoft\WebsiteCache
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files
:)
Unlimited Connection TimeOut in Asp.net and SQL
Sometimes when we are executing a Stored procedure from Asp.net which takes a lot of time,which leads to connection TimeOut problem.
There are two ways to increase connection TimeOut.
1) From Asp.net Web.config
2) From Sql Server database setting.
For Asp.net got to web.config connection string and set Connection timeout Property to 0(Zero).
For Sql Server right click on Server => Properties . then a server properties page will open , from left hand side menu select Connections and set Remote query timeout to 0.
I hope somebody will find this useful.
There are two ways to increase connection TimeOut.
1) From Asp.net Web.config
2) From Sql Server database setting.
For Asp.net got to web.config connection string and set Connection timeout Property to 0(Zero).
For Sql Server right click on Server => Properties . then a server properties page will open , from left hand side menu select Connections and set Remote query timeout to 0.
I hope somebody will find this useful.
How to set gzip/deflate compression in .net.
To enable Gzip and deflate compression in Asp.net website, you just need to place this code in global.asax.
however you can also apply this setting to IIS level.
void Application_PreRequestHandlerExecute(object sender, EventArgs e)
{
try
{
HttpResponse Response = HttpContext.Current.Response;
String AcceptEncoding = HttpContext.Current.Request.Headers["Accept-Encoding"];
however you can also apply this setting to IIS level.
void Application_PreRequestHandlerExecute(object sender, EventArgs e)
{
try
{
HttpResponse Response = HttpContext.Current.Response;
String AcceptEncoding = HttpContext.Current.Request.Headers["Accept-Encoding"];
Subscribe to:
Posts (Atom)