Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ASP says not a table
Message
From
11/09/2007 12:48:10
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
10/09/2007 15:14:21
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01252602
Message ID:
01253718
Views:
22
>>>>Maybe it is a table that ODBC driver can't handle. Why do you use OLEDB for ODBC driver and not directly VFPOLEDB driver?
>>>>Cetin
>>>Thanks Cetin -
>>>The answer to your question is "because I'm not educated enough to know there are choices and what the difference might be." Are you suggesting a different connection string?
>>
>>Yes. If you don't have it download latest driver from MS vfoxpro downloads. It is publicly available.
>>
>>Set oConn = Server.CreateObject("ADODB.Connection")
>>ConnStr = "Provider=VFPOLEDB;Data source=c:\inetpub\wwwroot\tip\login\data\tipdatabase.dbc"
>>
>>Cetin
>
>Cetin -
>
>I took your advice and got it working for readonly. Now if I want the cursor to be updateable, what else do I need? I currently have:
>
>< %
>Set oConn = Server.CreateObject("ADODB.Connection")
>ConnStr = "Provider=VFPOLEDB;Data source=c:\inetpub\wwwroot\tip\login\data\tipdatabase.dbc"
>oConn.Open ConnStr
>
>DIM SQL, oRS
>SQL = "SELECT * FROM Users WHERE Username = '" & strUsername & "'"
>Set oRS = Server.CreateObject("ADODB.Recordset")
>oRS.Open SQL, oConn
>% >
>
>I seems I need something more on the last line to deal with the buffering but I don't know what. The common tutorials use values like adOpenKeyset, adLockPessimistic, and adCmdText that don't seem to work with the VFP driver. Is there a tutorial available that is specific to the VFPOLEDB driver?
>
>Thanks


Don,
This code sample is old but works:
<%
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;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
%>
If you'd first get an RS and update it then the important setting is adUseClient:
oCon.ConnectionString = "Provider=VFPOLEDB;Data Source=blah blah\testdata.dbc"

' Alternative one at a time
'oCommand.CommandText = "insert into employee (emp_id,first_name,last_name,birth_date,notes)" & _
'  " values ('test3','First3','Last3',{^1961/1/19},?)"
'oCommand.CommandType = adCmdText
'Set oParm = oCommand.CreateParameter("Notes", adVarChar, adParamInput, Len(myMemo), myMemo)
'oCommand.Parameters.Append oParm
'oCon.Open
'oCon.Execute ("set null off")
'oCommand.ActiveConnection = oCon
'oCommand.Execute
'oCon.Close

oCon.Mode = adModeShareDenyNone
oCon.Open
oCon.CursorLocation = adUseClient
oCon.Execute ("set null off")
oRS.Open "employee", oCon, adOpenKeyset, adLockBatchOptimistic, adCmdTable
oRS.AddNew
oRS.Fields("emp_id").Value = "test1"
oRS.Fields("First_Name").Value = "First1"
oRS.Fields("Last_Name").Value = "Last1"
oRS.Fields("hire_date").Value = #1/13/2004#
oRS.AddNew
oRS.Fields("emp_id").Value = "test3"
oRS.Fields("First_Name").Value = "First2"
oRS.Fields("Last_Name").Value = "Last2"
oRS.Fields("hire_date").Value = #2/29/2000#
oRS.Fields("Notes").Value = myMemo
oRS.UpdateBatch
oRS.Close
oCon.Close
And finally of course your internet account must have read and write access to tables.
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform