If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Connect to sql db vbscript in ASP

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-16-09, 11:18
ismailc2 ismailc2 is offline
Registered User
 
Join Date: Apr 2009
Posts: 2
Question Connect to sql db vbscript in ASP

Good day,

Need to connect & retrieve from SQL DB in aspx page using vbscript server side

I have an html page which I want to edit by adding information from a SQL database & display results on and in the html page (code below).

Any code would be great that works in the aspx page where i can just insert the DB connection details & sql statement & display the result on page.

Please Assist
Reply With Quote
  #2 (permalink)  
Old 04-16-09, 20:52
myle myle is offline
(Making Your Life Easy)
 
Join Date: Feb 2004
Location: New Zealand
Posts: 1,110
it can't be done in HTML
HTML is DUM all it does to format and display the DATA


Code:
Dim connstring   'conection string
Dim rs   'recordset name
Dim SQL   'sql
Dim my_Conn
set my_Conn = Server.CreateObject("ADODB.Connection")
set connstring = Server.CreateObject("ADODB.Connection")

connstring.Open "Provider=SQLOLEDB; Data Source = (local); Initial Catalog = #####;User Id =####; Password=######"
if you save as a inc file

at the top of the ASP pages
<!-- #include file="inc/adovbs.inc" -->
<!--#include file="inc/opendb.inc"-->

mine is called opendb.inc and its in the inc folder.

now get the DATA

1st create a record object
Set Rs = Server.CreateObject("ADODB.Recordset")
2 create the SQL
SSQL = ""
SSQL = SSQL & "SELECT [Note to PDF Sum].* FROM [Note to PDF Sum]"
3 open the SQL or table must be sql statment
Rs.Open SSQL, connstring, adOpenKeyset, adLockPessimistic, adCmdText
4 now we can do some thing

do until rs.eof
...
..
..
rs.movenext
loop
rs.close
set rs = nothing
__________________
hope this help

See clear as mud


StePhan McKillen
the aim is store once, not store multiple times
Progaming environment:
Access based on my own environment: DAO3.6/A97/A2000/A2003
VB based on my own environment: vb6 sp5
ASP based on my own environment: 5.6
VB-NET based on my own environment started 2007
SQL-2005 based on my own environment started 2008
MYLE
Reply With Quote
  #3 (permalink)  
Old 04-18-09, 10:51
ismailc2 ismailc2 is offline
Registered User
 
Join Date: Apr 2009
Posts: 2
Wink

Thanks a million for the help, really apprecaite it.

I have been struggling for a while, the ascs page displays the as text but not the results from the query, i thought of a workaround creating a report - with a iframe in the header with not borders & the page look's like one.


Thank You
Reply With Quote
  #4 (permalink)  
Old 04-19-09, 06:57
myle myle is offline
(Making Your Life Easy)
 
Join Date: Feb 2004
Location: New Zealand
Posts: 1,110
yeap that can be done but you must walk before u run
iframe will do the job but that hard once you under stand part1 then play around with part 2 ok.
__________________
hope this help

See clear as mud


StePhan McKillen
the aim is store once, not store multiple times
Progaming environment:
Access based on my own environment: DAO3.6/A97/A2000/A2003
VB based on my own environment: vb6 sp5
ASP based on my own environment: 5.6
VB-NET based on my own environment started 2007
SQL-2005 based on my own environment started 2008
MYLE
Reply With Quote
Reply

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 On
Pingbacks are On
Refbacks are On