Go Back   DeveloperBarn Forums > Programming & Scripting > ASP Development

Sponsored Links

Discuss "Is this valid ASP/ADO Code" in the ASP Development forum.

ASP Development - Learn coding practices and tips to get the best out of your Active Server Pages (ASP). The Classic ASP forum is for ASP/VBScript and ASP/JScript applications.


Closed Thread « Previous Thread | Next Thread »  
 
LinkBack (1) Thread Tools Display Modes
  1 links from elsewhere to this Post. Click to view. #1  
Old April 3rd, 2008, 03:16 PM
Wolffy's Avatar
Slaprentice of Wolves

 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 175
Thanks: 3
Thanked 24 Times in 21 Posts
Rep Power: 1
Wolffy is on a distinguished road

Awards Showcase
Microsoft .Net 
Total Awards: 1

Default Is this valid ASP/ADO Code

I've never coded in ASP -- but see enough of it, especially in conversion to ASP.NET, that I need at least a reading knowledge of it. It the following snippet valid ASP/ADO code:
Code:
<%
set conn=Server.CreateObject("ADODB.Connection")
conn.Provider="Microsoft.Jet.OLEDB.4.0"
conn.Open(Server.Mappath("/db/northwind.mdb"))
set sqlString = "Select * from Customers"
rs = conn.Execute(sqlString)
conn.close

do until rs.EOF
      for each x in rs.Fields
            Response.Write(x.name)
            Response.Write(" = ")
            Response.Write(x.value & "<br />")      
      next
      Response.Write("<br />")
      rs.MoveNext
loop

rs.close
%>
Note specifically the placement of the conn.close command. The mantra in ADO.NET has been 'open late, close early'
Sponsored Links
  #2  
Old April 3rd, 2008, 03:18 PM
jmurrayhead's Avatar
The Barnfather

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 819
Thanks: 20
Thanked 74 Times in 71 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura about

Awards Showcase
Microsoft Windows Microsoft .Net Microsoft SQL Server Classic ASP 
Total Awards: 4

Default

Nope, conn.close would have to be placed after rs.close or you would get an error.
__________________
jmurrayhead
If you agree with me... click the icon!
If my post solved your problem, click the button in the lower right-hand corner of the post.

Join our Folding team: DeveloperBarn Folding
  #3  
Old April 3rd, 2008, 03:22 PM
Wolffy's Avatar
Slaprentice of Wolves

 
Join Date: Mar 2008
Location: Peoria, IL
Posts: 175
Thanks: 3
Thanked 24 Times in 21 Posts
Rep Power: 1
Wolffy is on a distinguished road

Awards Showcase
Microsoft .Net 
Total Awards: 1

Default

Ah ha. So then I could think of a RecordSet is like a DataReader in my .NET oriented brain! There being nothing like a DataTable object in ADO into which I could return the entire result set.
  #4  
Old April 3rd, 2008, 03:24 PM
jmurrayhead's Avatar
The Barnfather

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 819
Thanks: 20
Thanked 74 Times in 71 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura about

Awards Showcase
Microsoft .Net Microsoft SQL Server Microsoft Windows Classic ASP 
Total Awards: 4

Default

Quote:
Originally Posted by Wolffy View Post
Ah ha. So then I could think of a RecordSet is like a DataReader in my .NET oriented brain! There being nothing like a DataTable object in ADO into which I could return the entire result set.
Yeap

Also, you will want to "set rs = conn.execute(sqlString)", not just "rs = conn.execute(sqlString)"

Comments on this post
Wolffy agrees: Knew I liked .NET for a reason. Have a rep point.
  #5  
Old April 14th, 2008, 08:12 AM
jmurrayhead's Avatar
The Barnfather

 
Join Date: Mar 2008
Location: Reston, VA, USA
Posts: 819
Thanks: 20
Thanked 74 Times in 71 Posts
Blog Entries: 5
Rep Power: 3
jmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura aboutjmurrayhead has a spectacular aura about

Awards Showcase
Microsoft .Net Microsoft SQL Server Microsoft Windows Classic ASP 
Total Awards: 4

Default

Quote:
Originally Posted by Wolffy View Post
Ah ha. So then I could think of a RecordSet is like a DataReader in my .NET oriented brain! There being nothing like a DataTable object in ADO into which I could return the entire result set.
Just wanted to add what I had forgotten...there is something that you can do: 4GuysFromRolla.com - Using Disconnected Recordsets
Closed Thread

  DeveloperBarn Forums > Programming & Scripting > ASP Development

Bookmarks

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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Wizard1 error The command 'MoveComplete' is not valid peebman2000 .Net Development 10 April 28th, 2008 02:52 PM

LinkBacks (?)
LinkBack to this Thread: http://www.developerbarn.com/asp-development/102-valid-asp-ado-code.html
Posted By For Type Date
[SOLVED] Is this valid ASP/ADO Code - DeveloperBarn Forums This thread Refback April 10th, 2008 03:54 PM


All times are GMT -4. The time now is 03:08 PM.



Content Relevant URLs by vBSEO 3.2.0