Hello, just wanted to offer a refresher for anyone who wants to connect to a SQL database with classic ASP on Lunarpages. If you have a Plesk account then you can create a new SQL database there. You can manage your database with MyLittleAdmin tool.
You have a database setup as follows:
Database Server: 209.200.235.3
Database Name: myDatabase
Database User: myUser
Database Password: myPassword
You have a table setup as follows:
TableName: myTable
ColumnName: myColumn
Datatype: varchar
You have sample data entered into the table:
Row 1: Hello World!
Row 2: John Doe
Now you want to display the records. Using your favorite web page editor like Dreamweaver, place the following code on a blank page called myTestPage.asp and upload it to the server via FTP.
<%
'open the connection
Dim Connect, myRecordSet
Set Connect = Server.CreateObject("ADODB.Connection")
Connect.Open = "Provider=MSDASQL;Driver={SQL Server};Server=209.200.235.3;Database=myDatabase;Uid=myUser;Pwd=myPassword;"
%>
<%
'display the data
Set myRecordSet = Connect.Execute ("SELECT * FROM dbo.myTable")
do until myRecordSet.EOF
response.write(myRecordSet("myColumn")&"<br>")
myRecordSet.MoveNext
loop
%>In the browser, go to
www.myDomainName.com/myTestPage.asp . The output displayed will be:
Hello World!
John Doe
Lunarpages has at least two SQL Servers, Castor and Raptor. You can access Castor with 209.200.235.3 and
http://lesuth.lunarpages.com/mylittleadmin . You can access Raptor with 209.200.244.115 and
http://lesuth.lunarpages.com/mylittleadmin2 .
Warning: databases are highly vulnerable to hackers. The SQL injection attacks and XSS (cross-site scripting) attacks are running rampant. So please ensure you have setup custom error pages and use ASP input validation as a precaution to ensure database security. For more info, check out:
http://www.ehow.com/how_4434719_protect-website-hacker-attacks.html .
Hope you may find this useful.
