Useful Links

Monday, January 28, 2008

Change File/Folder permissions on godaddy web server

Following is the process to set up permissions on a godaddy account:

Login using your user name/account number and password
Click on My Account
Click on Hosting Account List
Click on Open (the web hosting package you want to open)
Scroll down to content and Click File Manager
Select the domain folder you want to set permissions for and click permissions button on the upper control bar
Set the required permissions and click OK

Friday, January 25, 2008

XML Path Conventions

using xml files:
before uploading:
path conventions

Server.MapPath("\abcsitename\registration")&"\xyz.xml"

after uploading:
path conventions

Server.MapPath("\registration")&"\xyz.xml"

Tuesday, September 18, 2007

Displaying records from an excel file

Aim of this articles is to display records from an Microsoft Excel in an ASP. We could use general SQL command while retreving data from an excel sheet. All we need to know how to connect Excel file.

Here is the excel database connection string :

Connection String for Excel

strConnection = "DBQ=" & Server.MapPath("customer-list.xls") & "; DRIVER={Microsoft Excel Driver (*.xls)};"

We will use a specific driver to connect to Excel files. ODBC plays a major role in coding.

An Example :


strConnection = "DBQ=" & Server.MapPath("customer-list.xls") & "; DRIVER={Microsoft Excel Driver (*.xls)};"

Set cn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
cn.open strConnection


sql="select * from sales_in_2005;"

rs.Open sql, cn, adOpenStatic, adLockPessimistic


do while not rs.eof
response.write rs("customerName") & " : " & rs("soldPrice") & "
"
rs.movenext
loop


rs.close
Set rs = nothing
cn.close
Set cn = nothing


In this example, we have used an example Excel files that holds some data containing customerName and soldPrice cells. We have displayed all cells with sample data on our page.

Happy Coding

Reading & Writing to an excel file

You can store data in a Microsoft Excel Spreadsheet and then use ASP to extract the infromation. The spreadsheet acts like a database and you can use standard SQL statements to query the data. The process is fairly simple and I will break it down into three steps:



STEP-1: Create an Excel Spreadsheet

STEP-2: Define named ranges in the spreadsheet

STEP-3: Write ASP code read the file



STEP-1:

Lets get started with the spreadsheet. You MUST have Microsoft Excel installed on your computer to create and Excel Spreadsheet. I have created a folder called "excel" under C:\Inetpub\wwwroot\
and thats where I will create/save my Excel spreadsheet.



a) Open Excel and create a spreadsheet that looks like this:







In this sheet the SR, NAME and EMAIL are the column names. When we query the data from this spreadsheet, we can limit the results by selecting only one or two columns e.g. SELECT NAME FROM my_range;



STEP-2:



Now that we have created a spreadsheet, its time to define a named range within Excel that will be treated as a table for our SQL statement. To create a named range, select all the fields that have data in them, with the column names, then go to INSERT > Name > Define... > Type in my_range > Press OK > Save your file in C:\inetpub\wwwroot\excel\excel.xls








I have saved my excel file as excel.xls.



STEP-3:



Now that we have the excel file and the named range in place, we can start working on the ASP code. Here is the code to read this excel file using a DSN-LESS approach










To test the code, point your browser to http://127.0.0.1/excel/read_excel.asp and you will see the following output:







You can customize the out anyway you want and the possibilities are endless :)



Enjoy and Happy ASP'ing.



Following are some links that were very helpful when I was digging up this information:




http://www.webdeveloper.com/forum/showthread.php?t=77596

http://www.carlprothman.net/Default.aspx?tabid=81

http://support.microsoft.com/kb/195951

MSDN


More Tutorials at http://www.NabeelAkhtar.NET

Tutorial Discussion Forums: http://Forum.NabeelAkhtar.NET

Friday, July 20, 2007

Methods and properties of Microsoft.XMLDOM

Document

Properties

asyncboolean: specifies whether asynchronous download of the document is permitted.
doctype
documentElement
implementation
ondataavailable [ie]
onreadystateChange [ie]
ontransformnode [ie]
parseError [ie]
preserveWhiteSpace [ie]
readyState
resolveExternals [ie]
setProperty ) [ie]The following (2nd level) properties can be set:
AllowDocumentFunction
ForcedResync
MaxXMLSize
NewParser
SelectionLanguage
SelectionNamespace
ServerHTTPRequest
for example: xmlDoc.setProperty("SelectionLanguage", "XPath");selection = xmlDoc.selectNodes("//Customer");
url [ie]
validateOnParse [ie]

Methods

abort [ie]
createAttribute
createCDATASection (data )
createComment (comment)
createDocumentFragment (data )
createElement (tagName)
createEntityReference (name )
createNode [ie] (type, name, nameSpaceURI)
createProcessingInstruction (target, data)
createTextNode (data)
getElementsByTagName (tagName)
load [ie] (url)
loadXML [ie] (xml_string)
nodeFromID [ie] (id_string)
save [ie] (objTarget)

For properties and methods of NODE object, visit the actual link: http://www.adp-gmbh.ch/web/js/msxmldom/methods_properties.html

Thursday, July 19, 2007

Create & Save an XML file using ASP

Create and Save an XML FileStoring data in XML files is useful if the data is to be sent to applications on non-Windows platforms. Remember that XML is portable across all platforms and the data will not need to be converted!
First we will learn how to create and save an XML file. The XML file below will be named "test.xml" and will be stored in the c directory on the server. We will use ASP and Microsoft's XMLDOM object to create and save the XML file:

'ASP CODE STARTS NOW
Dim xmlDoc, rootEl, child1, child2, p'Create an XML document
Set xmlDoc = Server.CreateObject("Microsoft.XMLDOM")'Create a root element and append it to the document
Set rootEl = xmlDoc.createElement("root")
xmlDoc.appendChild rootEl'Create and append child elements
Set child1 = xmlDoc.createElement("child1")
Set child2 = xmlDoc.createElement("child2")
rootEl.appendChild child1
rootEl.appendChild child2'Add an XML processing instruction
'and insert it before the root element
Set p=xmlDoc.createProcessingInstruction("xml","version='1.0'")
xmlDoc.insertBefore p,xmlDoc.childNodes(0)'Save the XML file to the c directory
xmlDoc.Save "c:\test.xml"
'ASP CODE ENDS HERE
For complete article, visit: http://www.w3schools.com/xml/xml_savedata.asp