UK WEB HOSTING FORUM FOR DISCUSSION ON WEB HOSTING SERVICE AND SUPPORT
LINUX HOSTING WINDOWS HOSTING PACKAGES SHOPPING CART OSCOMMERCE ZEN CART AGORA
ECOMMERCE HOSTING ASP MSSQL FRONTPAGE HOSTING PHP MYSQL HOSTING DISCUSSION FORUM
CPANEL RESELLER HOSTING DEDICATED SERVER VPS HOSTING PLESK VIRTUOZZO
Quick Search
Your forum announcement here!

  eUKhost's Official Web Hosting Forum > Technical Support > Tutorials / How to?

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 17-07-2009, 07:03
Moderator
 
Join Date: Nov 2008
Posts: 60
Default Display the Contents of MSSQL database on your website using ASP.NET

Hello ,

Here I will explain the steps to connect to a database using a Data Source Name (DSN)


1) Lets assume that you have a MSSQL database with Your data in it . Give the database user db_owner, db_datareader and db_datawriter permission.

2) Create DSN from start==>programs==>administrative tools==>data sources==>system dsn==>
add ==> Select SQL server and click finish. A wizard will be opened , put in the DSN name lets name it datasource , the sql server which you want to connect to , Click Next select the option With SQL server authentication using a login ID and password entered by the user . Click next,next and finish the DSN creation wizard .

3) The DSN will be used in our script to connect to the database . Create a ASP file under you website root folder say displaydata.asp and use the following VBscript which is the default language of ASP.NET


<%@ Language=VBScript %>
<% Option Explicit %>
<%
Dim StartTime, EndTime

StartTime = Timer

Dim objCN ' ADO Connection object
Dim objRS ' ADO Recordset object
Dim strsql ' SQL query string
Dim strTemp ' a temporary string

' Create a connection object
Set objCN = Server.CreateObject("ADODB.Connection")

' Connect to the data source
objCN.ConnectionString = "DSN=datasource;UID=dbuser;PWD=passw0rd"
objCN.Open

' Prepare a SQL query string
strsql = "SELECT * FROM tablename"

' Execute the SQL query and set the implicitly created recordset
Set objRS = objCN.Execute(strsql)

' Write out the results in a table by concatenating into a string
Response.write "<table>"

Do While Not objRS.EOF
strTemp = strTemp & "<tr><td>" & objRS("Column Name") & "</td>"
strTemp = strTemp & "<td>" & objRS("Column Name") & "</td>"
strTemp = strTemp & "<td>" & objRS("Column Name") & "</td>"
'strTemp = strTemp & "<td>" & objRS("Column Name ") & "</td></tr>"
objRS.MoveNext
Loop
Response.write strTemp
Response.write "</table>"

Set objCN = Nothing
Set objRS = Nothing

EndTime = Timer
Response.write "<p>processing took "&(EndTime-StartTime)&" seconds<p>&nbsp;"
%>

Test Results

Regards,

Euk-Paul.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off



All times are GMT. The time now is 03:40.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
UK Web Hosting by eUKHosting 3.1.0
UK Web Hosting by eUKHosting 3.1.0
Copyright © 2001-2012, eUKhost LTD. All rights reserved.

 


UK VPS Hosting
VPS Hosting plans

Dedicated Server Hosting
Dedicated Server plans

VoIP Dedicated Servers
Asterisk, Trixbox Dedicated Servers

Business Web Hosting
100% uptime Hosting

UK Cpanel Hosting
cPanel Shared Hosting

Domain Hosting
Cheap Domains & Hosting Plans

UK Reseller Hosting
Reseller Web Hosting

Windows Hosting
Windows Shared Hosting

Windows VPS

Windows VPS Hosting

Semi Dedicated Servers
Semi-Dedicated Hosting

Dedicated Server Mirroring
Dedicated Server Mirroring

Webhosting Knowledgebase
Frequently asked Questions

Web Hosting Blog
eUKhost Blog

Web Hosting Support
Support Helpdesk

UK Data Center
eUKhost Datacenter

Web Hosting Forum
eUKhost Forum

Support Tutorials
Online Flash Tutorials

Offsite Back-up Plans
Remote Backup Service

ColdFusion Hosting
ColdFusion Web Hosting
 
 

Android and Apple App


knowledgebase articles
eUKhost.com Services

Pre-Sales Questions
Pre-sales FAQ's

Domain Names
Domain registration FAQ's

cPanel Hosting
cPanel Hosting FAQ's

Windows Web Hosting
Plesk Control Panel

Reseller Hosting
Reseller Hosting FAQ's

VPS Hosting
Virtual Private Server

Semi-Dedicated Servers
Semi-Dedicated FAQ's

Dedicated Servers
Dedicated Server Hosting

Joomla Hosting
Joomla Web Hosting

Mambo Hosting
Mambo Web Hosting

Magento Hosting
Magento Web Hosting

Wordpress Hosting
Wordpress Web Hosting

 

Web Hosting Affiliate Program
 

popular blog categories

UK Web Hosting
UK Hosting articles

Dedicated Server Hosting
Dedicated Server guidelines

VPS Hosting
VPS hosting articles

cPanel Hosting
cPanel Hosting articles

Linux Operating System
Linux Operating techniques

Windows Web Hosting
Windows plesk articles