Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
Old 03-23-2006, 02:37 PM Data to Variable
bman's Avatar
Skilled Talker

Posts: 85
Location: USA
Trades: 0
Q.

I understand how to get the data into a dataset. Thats when things get murky, I don’t know how to get data out and into a variable, for manipulation, then back in. Also is there a name space I must add?

You know how in PHP, when you get returned values in a array then you access the array to change the value or view it. The data is stored in a variable that can be manipulated then sent back to updated in the db.



My problem is how does ASP do this? ‘For instance, Let say I have a users form info, how do I take that info and insert it into the dB? ‘



Please help, this appears to be one of my last hurdles of understanding for what I need to know,

To reasonable start programming in ASP



I have tried to find information on this subject, but people avoid it. I'm missing something!

Are there example I can view of this process?



Thanks anyone!
bman is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-23-2006, 04:34 PM Re: Data to Variable
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
www.asp101.com/samples/
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-24-2006, 01:53 AM Re: Data to Variable
Super Talker

Posts: 144
Trades: 0
here's an example using the ADO Component

Code:
<%
  on error resume next
 
  dim conn, rs, column
 
  set conn = server.createObject("ADODB.Connection")
 
  if err.number <> 0 then
    response.write "there was an error creating the connection object<br><br>"& err.description
  else
    ' the following line gives you access to rs.recordCount so we know how many rows were affected by the query
    conn.cursorLocation = 3
 
    ' the following line establishes a connection to the database server
    ' there are different types of "connections trings" see http://www.connectionstrings.com for the one that works best for you
    conn.open "Provider=sqloledb;Data Source=Aron1;Initial Catalog=pubs;User Id=sa;Password=asdasd;"
 
    ' now we check to ensure there were no errors
    if err.number <> 0 then
      response.write "there was an error opening the database connection<br><br>"& err.description
    else
      ' there were no errors
      ' select data from the database table and return that data into a 'record set' object
 
      set rs = conn.execute("SELECT column1, column2, column3 FROM table WHERE column1 = 'some value'")
 
      ' the variable "rs" is our record set object and contains all the data returned from the query
 
      ' we will check for 'rs.eof' which is typically "end of file," in this case, end of records
      if not rs.eof then
        ' put the record set at the first record or "returned row"
        ' although, it should be at the first row when returned from the conn.execute function
        rs.moveFirst
 
        response.write "<h1>returned "& rs.recordCount &" row(s)<br>"
        response.write "<table cellspacing=10><tr>"
        ' loop through each member or "column"
        for each column in rs
          response.write "<th>"& column &"</th>"
        next
 
        response.write "</tr>"
        ' loop through the record set and output each value row by row
        while not rs.eof
          response.write "<tr>"
          response.write "<td width=300>"& rs("column1") &"</td>"
          response.write "<td width=300>"& rs("column2") &"</td>"
          response.write "<td width=300>"& rs("column3") &"</td>"
          response.write "</tr>"
 
          ' move the record set to the next record or "returned row"
          rs.moveNext
        loop
 
        ' notice how first I used a for-each to loop through, and the second time, I just manually referred to each column
        ' now you know how to do it both ways.  to output the value in the first for-each loop, you would have used, "rs(column)"
 
        response.write "</table>"
      else
        response.write "<h1>no records were returned from the query</h1>"
      end if
 
      ' destroy the record set object
      set rs = nothing
 
      ' close the connection
      conn.close
    end if
  end if
 
  ' destroy the connection object
  set conn = nothing
%>
__________________
create.vibe

Please login or register to view this content. Registration is FREE
createvibe.com is offline
Reply With Quote
View Public Profile Visit createvibe.com's homepage!
 
Reply     « Reply to Data to Variable
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.33466 seconds with 12 queries