Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Problem with simple data access with ASP and ADO
Message
De
19/09/2003 06:52:29
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
18/09/2003 17:32:10
Chris Crachiolo
Blackmoor Associates Incorporated
New York City, New York, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Applications Internet
Divers
Thread ID:
00830492
Message ID:
00830600
Vues:
13
>As usual, I'm at least 5 years behind everybody else and am currently exploring web development. Working through some very basic examples in Rick Strahl's "Internet Access with Visual FoxPro 6.0" I've run into a problem (pg. 63-64) and I'm stumped.
>
>I'm accessing a VFP table (ODBC System Data Source) through ASP pages using ADO. The first ASP page adds records to the VFP table -- that works flawlessly. The second ASP page tries to read through that table and display the data -- but the returned recordset is always empty (EOF is true). The code is not crashing per se (at least not at that point -- it only crashes when it tries to display field values for records that aren't there) -- I can add code to display properties of the recordset, which works, so the recordset is there, but there are no records therein. But there should be.
>
>I'm running XP with IIS 5.1 (using IIS as "localhost"), and I just downloaded and installed the latest versions of MDAC and the VFP ODBC driver (didn't help). The VFP table isn't open anywhere else when I access the page, I've double-checked my settings, changed the SQL statement in various ways, etc. There's no apparent problem with the code that I'm cutting and pasting from the PDF copy of the book. I'm still clueless. I must be missing SOMETHING -- some setting somewhere -- but what????

Why are you using OLEDB driver for ODBC when there is VFPOLEDB driver (just easier to set).

If you provided the code we might have some idea why it's failing. It seems you don't have access rights problem as you state you can add to table.

Here is a little sample code - hope helps :
<%
cSQLSelect = _
  "select * from employee where !isnull(birth_date) and !isnull(hire_date)"
cSQLInsert = "insert into employee" &_
  " (emp_id,First_name,last_name,hire_date)" &_
  " values ('CBASOZ','Cetin','Basoz',date())"
cSQLUpdate = "update testdata!employee " &_
   "set " &_
   "Birth_date = {^1961/01/19}, "	& _
   "Title = 'FoxyClasses Developer' " & _
   "where emp_id = 'CBASOZ'" 
cStoredProcCall = "myStoredProc('ReverseMe')"

    dbpath = Server.MapPath("data")
    set oConnection = Server.CreateObject( "adodb.connection" ) 
    with oConnection
       .ConnectionString = _
          "Provider=VFPOLEDB.1;data source=" & dbpath & "\testdata.dbc"
       .Open
       .Errors.Clear
       .Execute( 'set null off')	
       .Execute( cSQLInsert )
       .Execute( cSQLUpdate )
       Set rs = .Execute( cSQLSelect )
    end with
    ' Check results
    Response.Write("<TABLE border='1'><TR><TD>Emp Id</TD>" & _
    "<TD>First Name</TD><TD>Last Name</TD>" &_
    "<TD>Title</TD><TD>Born</TD><TD>Hired</TD></TR>" )
    while not rs.eof
            Response.Write("<TR>")
            Response.Write("<TD>" & rs.Fields("emp_id").value & "</TD>")
            Response.Write("<TD>" & rs.Fields("first_name").value & "</TD>")
            Response.Write("<TD>" & rs.Fields("last_name").value & "</TD>")
            Response.Write("<TD>" & rs.Fields("title").value & "</TD>")
            Response.Write("<TD>" & _
              DatePart("yyyy",rs.Fields("birth_date").value) & "/" & _
              DatePart("m",rs.Fields("birth_date").value) & "/" & _
              DatePart("d",rs.Fields("birth_date").value) & "</TD>")
            Response.Write("<TD>" & rs.Fields("hire_date").value & "</TD>")
            Response.Write("</TR>")
            rs.MoveNext
    wend
    Response.Write("</TABLE><BR/>")
	
'	set rsc = oconnection.execute( cStoredProcCall )
'	response.write(rsc.fields(0).value)
	
    oConnection.Close
    set oConnection = nothing
%>
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform