Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Newbie Here!!!

 
Logged in as: Guest
arrSession:exec spGetSession 2,3,32999
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> ASP >> Newbie Here!!!
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Newbie Here!!! - 4/3/2006 10:18:35 PM   
  cerberus1983

 

Posts: 2
Score: 0
Joined: 4/3/2006
Status: offline
Hi all,
     I'm kinda new to the whole ASP scene.  I'm currently designing a system that needs to have data entered into it and also data retrieved from the access database.  I have got the data entered in no problem but havent got a clue on how to retrieve this data.  I was wondering could someone shed some light on this for me. 

Kind Regards

cerberus1983
 
 
Post #: 1
 
 RE: Newbie Here!!! - 4/4/2006 4:08:09 AM   
  VBS

 

Posts: 110
Score: 0
Joined: 3/2/2005
From: Lebanon
Status: offline
Hey there,
First welcome to the ASP club

I really wanna help u, but could u plz attach ur code so that i could be able to tell exactly how to do it

Best Regards
Firas S Assaad

_____________________________

Anything in VB or VBScript or ASP email me or IM on firas489@hotmail.com or firas489@gmail.com

(in reply to cerberus1983)
 
 
Post #: 2
 
 RE: Newbie Here!!! - 4/4/2006 4:35:30 AM   
  Snipah


Posts: 1341
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
  Cerberus1983,

This is how I have setup my pages:


' Create and establish data connection
Set DataConn = Server.CreateObject("ADODB.Connection")
DataConn.ConnectionTimeout = 15
DataConn.CommandTimeout = 30

'Access connection code

'SQL Server code
DataConn.Open "Provider=SQLOLEDB;Data Source=10.2.1.214;" _
& "Initial Catalog=samples;User Id=samples;Password=password;" _
& "Connect Timeout=15;Network Library=dbmssocn;"


' Create and link command object to data connection then set attributes and SQL query
Set cmdDC = Server.CreateObject("ADODB.Command")
cmdDC.ActiveConnection = DataConn
cmdDC.CommandText = "SELECT * FROM sample WHERE (sales " & strLTorGT & " " & iCriteria & ") ORDER BY " & strSortBy & strOrder & ";"
cmdDC.CommandType = 1

' Create recordset and retrieve values using command object
Set rsDC = Server.CreateObject("ADODB.Recordset")
' Opening record set with a forward-only cursor (the 0) and in read-only mode (the 1)
rsDC.Open cmdDC, , 0, 1
%>


<p><strong>Results of <%= cmdDC.CommandText %></strong></p>

<table border="1">
<thead>
<tr>
<% For Each Item in rsDC.Fields %>
<th><%= Item.Name %></th>
<% Next %>
</tr>
</thead>
<%
' Loop through recordset and display results
If Not rsDC.EOF Then rsDC.MoveFirst

' Get the number of fields and subtract one so our loops start at 0
iFieldCount = rsDC.Fields.Count - 1

' Continue till we get to the end, and while in each <TR> loop through fields
Do While Not rsDC.EOF
%>
<tr>
<% For iLoopVar = 0 to iFieldCount %>
<td><%= rsDC.Fields(iLoopVar) %></td>
<% Next %>
</tr>
<%
rsDC.MoveNext
Loop
%>

</table>

<%
' Close Data Access Objects and free DB variables
rsDC.Close
Set rsDC =  Nothing
' can't do a "cmdDC.Close" !
Set cmdDC = Nothing
DataConn.Close
Set DataConn = Nothing
%>


<br />

<strong>Build your own query:</strong>
<form action="<%= Request.ServerVariables("URL") %>" method="get">
Sales:
<input type="radio" name="LTorGT" value="LT" checked />Less Than
<input type="radio" name="LTorGT" value="GT" />Greater Than
<input type="text" name="criteria" value="4500" size="10" />
<br />
Sort By:
<select name="sortby">
<option value="id">ID</option>
<option value="last_name">Last Name</option>
<option value="first_name">First Name</option>
<option value="sales">Sales</option>
</select>
<select name="order">
<option value="">Ascending
<option value=" DESC">Descending
</select>
<br />
<input type="submit" value="Run Query" />
</form>

_____________________________

For more information, please see the "Read me First" topic.

http://www.visualbasicscript.com

(in reply to cerberus1983)
 
 
Post #: 3
 
 RE: Newbie Here!!! - 4/5/2006 6:23:51 PM   
  VBS

 

Posts: 110
Score: 0
Joined: 3/2/2005
From: Lebanon
Status: offline
Hello,
First iam sorry for being late in replying, cause i was very busy

your code looks fine, but to be able to retrieve the data

change

rsDC.Open cmdDC, , 0, 1

into

rsDC.Open cmdDC, DataConn,2,3
 
 
I hope it works with u
 
Please tell me what happens with u
 
 
Best Regards
Firas S Assaad

_____________________________

Anything in VB or VBScript or ASP email me or IM on firas489@hotmail.com or firas489@gmail.com

(in reply to Snipah)
 
 
Post #: 4
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> ASP >> Newbie Here!!! Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts