Tuesday, 8 January 2013

Browser detection in asp

Browser detection in asp
----------------------------------------------------------------------------------------------------------------------
<%=response.write(request.servervariables("HTTP_USER_AGENT"))%>

(or) use try the following code
<%
Set browserdetect = Server.CreateObject("MSWC.BrowserType")
' find some properties of the browser being used to view this page
browser=browserdetect.Browser
version=browserdetect.Version
majorver=browserdetect.Majorver
minorver=browserdetect.Minorver
platform=browserdetect.Platform
frames=browserdetect.Frames
tables=browserdetect.Tables
cookies=browserdetect.Cookies
javascript=browserdetect.JavaScript
' send some output to the web browser
response.write ("Browser: " & browser & "<BR>")
response.write ("Version: " & version & "<BR>")
response.write ("Majorver: " & majorver & "<BR>")
response.write ("Minorver: " & minorver & "<BR>")
response.write ("Platform: " & platform & "<BR>")
response.write ("Supports frames: " & frames & "<BR>")
response.write ("Supports tables: " & tables & "<BR>")
response.write ("Supports cookies: " & cookies & "<BR>")
response.write ("Supports JavaScript: " & javascript & "<BR>")
%>

Friday, 28 December 2012

copy table content from one db to another db

Copy Table Content from one DB to another DB.
----------------------------------------------------------------------------------------------------------------------
SELECT * INTO targetdbname..tablename FROM sourcedb..tablename
Using the above command you can copy the table content from one SQL DB to Another SQL DB 

----------------------------------------------------------------------------------------------------------------------
INSERT INTO tablename(field1,field2) SELECT field1,field2 FROM tablename

Using the above command you can copy the table content from one table to Another table   


Tuesday, 6 November 2012

Video Players in ASP

Download the Web's most advanced video player.
----------------------------------------------------------------------------------------------------------------------
http://www.longtailvideo.com/players/jw-flv-player/



Wednesday, 17 October 2012

list multiple files in single folder - asp

How to List Multiple Files in a Single Folder
----------------------------------------------------------------------------------------------------------


Dim myobjFS, myobjFile, myobjFolder

Set myobjFS = Server.CreateObject("Scripting.FileSystemObject")
Set myobjFolder = myobjFS.GetFolder(Server.MapPath("/folderpath"))

For Each myFile in myobjFolder.Files
Response.Write myFile.Name & "<br>"
Next
Set myobjFolder = Nothing
Set myobjFS = Nothing

----------------------------------------------------------------------------------------------------------

How To Move Multiple Files from One Folder to another



Dim myobjFSO, myobjFolder, myFile
Dim myFolder, myTarFolder

Set myobjFSO = Server.CreateObject("Scripting.FileSystemObject")

Set myobjFolder = myobjFSO.GetFolder("D:\Sourcefolder\")
myTarFolder = "D:\Targetfolder\backup\"

For Each myFolder in myobjFolder.SubFolders

For Each myFile in myFolder.Files
if myobjFSO.FileExists(myFile)=true then
myobjFSO.CopyFile myFile,myTarFolder&myFolder.Name&"\"
                'myobjFSO.MoveFile myFile,myTarFolder&myFolder.Name&"\"
myobjFSO.DeleteFile myFile
end if
Next
Next

Set myobjFolder = Nothing
Set myobjFSO = Nothing


----------------------------------------------------------------------------------------------------------
Count Files in a Folder

myFolder.Files.count (Check the above code for reference)

----------------------------------------------------------------------------------------------------------

Tuesday, 16 October 2012

Replace Single Quotes in SQL SERVER

Replace Single Quotes in SQL SERVER
---------------------------------------------------------------------------------------------------------


@result=how to remove single quote's
REPLACE(@result,char(39),'')  (or) REPLACE(@result,char(39),char(39)+char(39))


---------------------------------------------------------------------------------------------------------

Friday, 12 October 2012

Delete, Move, Copy, File Exists in asp


DeleteFile

The following example uses the DeleteFile method to delete a single file. It requires a physical path to the file so we have used Server.MapPath to find the physical path of a file, which is in the same directory as the script.

Set FS = Server.CreateObject("Scripting.FileSystemObject")
FS.DeleteFile Server.MapPath("file.ext")

The DeleteFile method does not have a return value and if it fails it will generate an internal server error. If the file does not exist it will have the message "File not found" with the error code 0x800A0035.

Multiple files can be deleted using wildcards. The following example deletes all text files from the directory containing the script.

Set FS = Server.CreateObject("Scripting.FileSystemObject")
FS.DeleteFile Server.MapPath(".") & "\*.txt"

Notice that DeleteFile can accept wildcards, but Server.MapPath cannot, so the physical path of the files to be deleted must be built by string addition. This code will also generate an error if no files match the description.

The star character is the most commonly used wildcard because matches any string of characters. The question mark can be used to replace a single character. The following example deletes all text files that have a name that is one character long.

Set FS = Server.CreateObject("Scripting.FileSystemObject")
FS.DeleteFile Server.MapPath(".") & "\?.txt"

MoveFile

The MoveFile method takes two parameters, the source and destination, which are physical paths. The destination file can be given a different name from the original so that it can be renamed as well as moved. This command will also give an error if the source files or the destination folder do not exist.

The following example moves a file from one directory to another while keeping the name unchanged.

Set FS = Server.CreateObject("Scripting.FileSystemObject")
FS.MoveFile "D:\source\a.txt", "D:\destintation\a.txt"

CopyFile

The CopyFile method is similar to the MoveFile method described above, except that the source file is not deleted. The following example copies a file from one directory to another while keeping the name unchanged.

Set FS = Server.CreateObject("Scripting.FileSystemObject")
FS.CopyFile "D:\source\a.txt", "D:\destintation\a.txt"

If a file by that name already exists in the destination folder, it will be overwritten. CopyFile has an optional third parameter which can be set to false to prevent overwriting. for example:

Set FS = Server.CreateObject("Scripting.FileSystemObject")
FS.CopyFile "D:\source\a.txt", "D:\destintation\a.txt", false

If the file already exists in the destination folder this code will generate an error saying "File already exists" with the code 0x800A003A.

Check if a file exists using the File System Object

The following example checks if a file exists. It uses a physical path to the file and returns true or false.

Set FSO = Server.CreateObject("Scripting.FileSystemObject")
Response.Write FSO.FileExists(FilePath)

Replace XML Special Characters in asp


Replace XML Special Characters in asp

==========================================================================

’ 226 128 153 
– 226 128 147 
“ 226 128 156 
†226 128 
… 226 128 166 


==========================================================================


DATA = Replace(DATA, Chr(226) & Chr(128) & Chr(153) , "'")
DATA = Replace(DATA, Chr(226) & Chr(128) & Chr(147) , "-")
DATA = Replace(DATA, Chr(226) & Chr(128) & Chr(166), "...")
DATA = Replace(DATA, Chr(226) & Chr(128) & Chr(156) , "''")
DATA = Replace(DATA, Chr(226) & Chr(128) , "''")
DATA = Replace(replace(DATA,"&lt;","<"),"&gt;",">")

==========================================================================