reading data from a database & storing it into temporary variables

Results 1 to 5 of 5

Thread: reading data from a database & storing it into temporary variables

  1. #1
    Join Date
    Dec 1969
    Posts
    30

    Default reading data from a database & storing it into temporary variables

    I am trying to read some data from an ACCESS data field. I want to store that data(a file name)into a temporary variable and then want to open that file for reading in ASP.<BR><BR>Can anybody help me with that?<BR>Thanx in anticipation.

  2. #2
    pnub Guest

    Default RE: reading data from a database & storing it into temporary variables

    Let&#039s take a simple example where you might have an Access database and have usernames and email address in two different columns named &#039name&#039 and &#039email&#039 respectively. You could do the following:<BR><BR>&#060;%<BR> Dim DB_CONNECTSTRING, objRecordset, strName, strEmail<BR> &#039&#039The following line is used to access an Access Database&#039&#039<BR> DB_CONNECTIONSTRING = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("example.mdb") & ";"<BR>&#037;&#062;<BR><BR>&#039&#039The following is needed for certain constants&#039&#039<BR>&#060;!-- #INCLUDE FILE="adovbs.inc" --><BR><BR>&#060;%<BR> &#039&#039Create a Recordset object&#039&#039<BR> Set objRecordset = Server.CreateObject("ADODB.Recordset")<BR><BR> &#039&#039Connect the Recordset to the table&#039&#039<BR> objRecordset.Open "scratch", DB_CONNECTIONSTRING, adOpenStatic, adLockPessimistic, adCmdTable<BR><BR> &#039&#039Moves cursor to first entry in database<BR> objRecordset.MoveFirst<BR> &#039&#039Set strName to "name" field&#039&#039<BR> strName = objRecordset.Fields("name")<BR> &#039&#039Set strEmail to "email" field&#039&#039<BR> strEmail = objRecordset.Fields("email")<BR> &#039&#039You could traverse through the database if you needed or&#039&#039<BR> &#039&#039find a particular entry, but setting the values it the&#039&#039<BR> &#039&#039same idea&#039&#039<BR><BR> &#039&#039Close the Recordset&#039&#039<BR> objRecordset.Close<BR> Set objRecordset = Nothing<BR><BR>That should help you understand it, although it might be more than you need. I&#039m sure you get the idea of how to set variables to certain values in a database.

  3. #3
    Join Date
    Dec 1969
    Posts
    30

    Default RE: reading data from a database & storing it into temporary variables

    I got your message. Actually it is the values stored within the database feilds( and not the field names themselves) which I want to retrieve.<BR><BR>Base on your suggestion I have been working on following code.<BR>&#039&#039Set strvi to "Input Voltage" field&#039&#039<BR>strvi = dbrs.Fields("Input Voltage")<BR>"&#039&#039Set newfile to value stored in the "Input Voltage" field&#039&#039<BR>newfile1 = strvi.value<BR><BR>This doesnt work. Could you sugget me any way to retrieve data stored WITHIN the fields? I am struggling at this since 3 days. Any suggestion is appreciated.<BR>Thanx,<BR>Shashin.

  4. #4
    Join Date
    Dec 1969
    Posts
    30

    Default I got the answer

    giving your suggestion a second thought I finally figuret out a way to do my stuff.<BR><BR>thanx for your help.


  5. #5
    Join Date
    Dec 1969
    Posts
    10

    Default RE: I got the answer

    How did you do it? Please share!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •