Wednesday, 30 November 2011
Diffrence between url and uri
For non-technical purposes you can generally consider 'URL' and 'URI' equivalent. In fact, URL is a special case of URI containing information on how to access the resource in question. Thus, since every URL is a URI (but not vice versa), 'URI' is generally preferable to 'URL', unless the identifier is known to be a locator.
URL specifies the location of the resource and also the protocol to be used.
where as URI is a name for anything that points to a resource
example:-
http:/www.xyz.com/login.jsp --> URL
www.xyz.com --> URI
URL specifies the location of the resource and also the protocol to be used.
where as URI is a name for anything that points to a resource
example:-
http:/www.xyz.com/login.jsp --> URL
www.xyz.com --> URI
Tuesday, 29 November 2011
Encrption And Decryption Of A Connection String
For Encryption Of A Coonection String Run this command on command prompt of administrator
After open command prompt type the following command aspnet_regiis.exe -pef "connectionStrings" "E:\website1"
now open your connection string look like this
For Decryption Of Connection String Type this Command
aspnet_regiis.exe -pdf "connectionStrings" "E:\website1"
After open command prompt type the following command aspnet_regiis.exe -pef "connectionStrings" "E:\website1"
After open web.config file in application and add sample db connection in connectionStrings section like this
<connectionStrings> <add name="Constr" connectionString="Data Source= Yogi-pc /Family; Integrated Security=true;Initial Catalog= YourDatabaseName; uid=YourUserName; Password=yourpassword; " providerName="System.Data.SqlClient"/> </connectionStrings > |
Example of declaring connectionStrings in web.config file like this
<connectionStrings> <add name="Constr" connectionString="Data Source=Yogi-pc /Family;Integrated Security=true;Initial Catalog=MySampleDB" providerName="System.Data.SqlClient"/> </connectionStrings > |
now open your connection string look like this
<connectionStrings configProtectionProvider="RsaProtectedConfigurationProvider">
<EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element"
xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#tripledes-cbc" />
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<EncryptedKey xmlns="http://www.w3.org/2001/04/xmlenc#">
<EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-1_5" />
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<KeyName>Rsa Key</KeyName>
</KeyInfo>
<CipherData>
<CipherValue>ZNUbIEnOwlZzC8qbzHj5F2GS9gLYSkWCIgCJGkrgZAX8A+8oF</CipherValue>
</CipherData>
</EncryptedKey>
</KeyInfo>
<CipherData>
<CipherValue>tODWlPD0Q/B/mP14GQ/5tUxcjmhHcy9a0oPunV5osNrMQRzt</CipherValue>
</CipherData>
</EncryptedData>
</connectionStrings>
For Decryption Of Connection String Type this Command
aspnet_regiis.exe -pdf "connectionStrings" "E:\website1"
Monday, 21 November 2011
date functions in sql.....
Declare @Date datetime set @Date = (SELECT GETDATE());print
-- Adding 5 days with Current Date @Date -- Print Current DateSELECT
DATEADD(month, 5,@Date ) AS NewTime-- Get Only YearSELECT DATEPART(year, GETDATE()) AS 'Year'-- Get Only MonthSELECT DATEPART(month, GETDATE()) AS 'Month'-- Get Only hourSELECT
DATEPART(hour, GETDATE()) AS 'Hour'-- Declare Two DateTime VariableDeclare @Date1 datetime Declare @Date2 datetime -- Set @Date1 with Current Dateset @Date1 = (SELECT GETDATE());-- Set @Date2 with 5 days more than @Date1set @Date2 = (SELECT DATEADD(day, 5,@Date1 ))-- Get The Date DifferenceSELECT
DATEDIFF(day, @Date1, @Date2) AS DifferenceOfDay-- Get Today SELECT DATENAME(dw, getdate()) AS 'Today Is'-- Get Mont nameSELECT
DATENAME(month, getdate()) AS 'Month'SELECT
DAY-----------15MONTH()SELECT
MONTH(getdate()) AS 'Month' Month-----------8YEAR()SELECT YEAR(getdate()) AS 'Year' DAY(getdate()) AS 'DAY'
-- Adding 5 days with Current Date @Date -- Print Current DateSELECT
DATEADD(month, 5,@Date ) AS NewTime-- Get Only YearSELECT DATEPART(year, GETDATE()) AS 'Year'-- Get Only MonthSELECT DATEPART(month, GETDATE()) AS 'Month'-- Get Only hourSELECT
DATEPART(hour, GETDATE()) AS 'Hour'-- Declare Two DateTime VariableDeclare @Date1 datetime Declare @Date2 datetime -- Set @Date1 with Current Dateset @Date1 = (SELECT GETDATE());-- Set @Date2 with 5 days more than @Date1set @Date2 = (SELECT DATEADD(day, 5,@Date1 ))-- Get The Date DifferenceSELECT
DATEDIFF(day, @Date1, @Date2) AS DifferenceOfDay-- Get Today SELECT DATENAME(dw, getdate()) AS 'Today Is'-- Get Mont nameSELECT
DATENAME(month, getdate()) AS 'Month'SELECT
DAY-----------15MONTH()SELECT
MONTH(getdate()) AS 'Month' Month-----------8YEAR()SELECT YEAR(getdate()) AS 'Year' DAY(getdate()) AS 'DAY'
diffrence between server.transfer and response.redirect
Server.Transfer v/s Response.RedirectBoth “Server” and “Response” are objects of ASP.NET. Server.Transfer and Response.Redirect both are used to transfer a user from one page to another page. Both are used for the same purpose but still there are some differences are there between both that are as follows: |
Response.Redirect(“newpage.aspx”) and Server.Transfer(“newpage.aspx”) |
Roundtrip means in case of Response.Redirect it first sends the request for the new page to the browser then browser sends the request for the new page to the webserver then after your page changes But in case of Server.Transfer it directly communicate with the server to change the page hence it saves a roundtrip in the whole process.
Suppose you are currently on the Page1.aspx and now you are transferring the user to the Page2.aspx using Response.Redirect then When the Page2 page is requested, Page1 has been flushed from the server’s memory and no information can be retrieved about it unless the developer explicitly saved the information using some technique like session, cookie, application, cache etc. But in case of Server.Transfer variables can stay in scope and Page2 can read properties directly from Page1 because it’s still in memory, as you know the Server.Transfer just changes the focus from page1 to page2 So in this case browser doesn’t know that any change is happen there that’s why with this method you can access the information about the previous page.
Actually in case of Server.Transfer it directly contact with the webserver for the new page request, it doesn’t involve the browser, so that browser doesn’t know that there is any change happen. But in case of Response.Redirect as you know it first send the request (for new page) to the browser then further processing will be performed, so here browser knows that yes there is some change in the browser window that’s why it changes the URL in the address bar. So, the matter “No change of address in the browser address bar” This is a good thing if you see it from security point of view but it creates problem in case if you refresh your page or in case you want to add bookmark of that page. In case of refresh and bookmark it will add perform both the action with the URL currently present in the address bar, but as you know Server.Transfer doesn’t changes the URL, so sometimes it creates problem.
With Response.Redirect you can redirect the user to the both type of pages .html or .aspx like below, Response.Redirect(“mypage.html”) OR Response.Redirect(“OtherPage.aspx”) But in case of Server.Transfer you can only work with .asp or .aspx page like below Server.Transfer(“mypage.asp”) OR Server.Transfer(“OtherPage.aspx”)
Suppose on some action on the webpage I want to redirect my user to the http://www.yahoo.com so with Response.Redirect you can redirect your user to the external site, but in case of Server.Transfer you can only work with the .asp or .aspx pages that are present in your site. Now the question is which to use and when to use? Mostly the Server.Transfer method is preferable to use because Server.Transfer is faster since there is one less roundtrip, but in some people say that Server.Transfer is not recommended since the operations typically flow through several different pages due to which you lose the correct URL of the page, but again all depends on your requirement. Server.Transfer also allows for more flexibility since you can use HTTPContext.Items to pass variables between pages so, use Server.Transfer when you need to pass context items. Otherwise use Response.Redirect so the user will always see the correct URL in the address bar. |
Thursday, 10 November 2011
using like Operator in Procedure sql server
CREATE PROCEDURE Proc_customersearch
@code nvarchar(10)=null,
@name nvarchar(20)=null
AS
begin
DECLARE @SQL nvarchar(500)
if((@code is not null) and (@name is null))
begin
SET @SQL = 'SELECT CustACNumber ,Cust_Name,Contactperson,Addressline1,Addressline2,postalcode,Telephoneno, Faxnumber,EmailID,Country,IATAAreacode,ControllinglocationCode,Cust_IataCode FROM M_customercodes WHERE CustAcNumber LIKE ''' + @code + '%''
'
EXEC (@SQL)
end
else if((@code is null) and (@name is not null))
begin
SET @SQL = 'SELECT CustACNumber ,Cust_Name,Contactperson,Addressline1,Addressline2,postalcode,Telephoneno, Faxnumber,EmailID,Country,IATAAreacode,ControllinglocationCode,Cust_IataCode FROM M_customercodes WHERE Cust_Name LIKE ''' + @name + '%'''
EXEC (@SQL)
end
else if((@code is not null) and (@name is not null))
begin
SET @SQL = 'SELECT CustACNumber ,Cust_Name,Contactperson,Addressline1,Addressline2,postalcode,Telephoneno ,Faxnumber,EmailID,Country,IATAAreacode,ControllinglocationCode,Cust_IataCode FROM M_customercodes WHERE Cust_Name LIKE ''' + @name + '%''
and CustAcNumber LIKE ''' + @code + '%'' '
EXEC (@SQL)
end
end
@code nvarchar(10)=null,
@name nvarchar(20)=null
AS
begin
DECLARE @SQL nvarchar(500)
if((@code is not null) and (@name is null))
begin
SET @SQL = 'SELECT CustACNumber ,Cust_Name,Contactperson,Addressline1,Addressline2,postalcode,Telephoneno, Faxnumber,EmailID,Country,IATAAreacode,ControllinglocationCode,Cust_IataCode FROM M_customercodes WHERE CustAcNumber LIKE ''' + @code + '%''
'
EXEC (@SQL)
end
else if((@code is null) and (@name is not null))
begin
SET @SQL = 'SELECT CustACNumber ,Cust_Name,Contactperson,Addressline1,Addressline2,postalcode,Telephoneno, Faxnumber,EmailID,Country,IATAAreacode,ControllinglocationCode,Cust_IataCode FROM M_customercodes WHERE Cust_Name LIKE ''' + @name + '%'''
EXEC (@SQL)
end
else if((@code is not null) and (@name is not null))
begin
SET @SQL = 'SELECT CustACNumber ,Cust_Name,Contactperson,Addressline1,Addressline2,postalcode,Telephoneno ,Faxnumber,EmailID,Country,IATAAreacode,ControllinglocationCode,Cust_IataCode FROM M_customercodes WHERE Cust_Name LIKE ''' + @name + '%''
and CustAcNumber LIKE ''' + @code + '%'' '
EXEC (@SQL)
end
end
date should not be insert be between two given date
SQL = "select * from paxR_AncillaryRevCode where AncillaryRevCode='" + objPrDCAncilloaryRevCode.AncillaryRevCode1 + "' and Convert(DateTime,'" + objPrDCAncilloaryRevCode.ValidFrom1 + "',103) between validFrom and ValidTo or convert(datetime,'" + objPrDCAncilloaryRevCode.ValidTo1 + "',103) between Validfrom and ValidTo and AncillaryRevCode='" + objPrDCAncilloaryRevCode.AncillaryRevCode1 + "' or Convert(DateTime,'" + objPrDCAncilloaryRevCode.ValidFrom1 + "',103)< convert(datetime,Validfrom,103) and convert(datetime,'" + objPrDCAncilloaryRevCode.ValidTo1 + "',103)> ValidTo and AncillaryRevCode='" + objPrDCAncilloaryRevCode.AncillaryRevCode1 + "'";
Subscribe to:
Comments (Atom)