client ใช้ jquery post มาไฟล์ update.asp แล้ว update ตาม เงื่อนไข
ตอน post มาผ่านครับ แต่ตอน update ใช้น้อย ไม่เป็นไร แต่พอมากๆเข้าเป็นครับ
-2147467259::[Microsoft][ODBC Visual FoxPro Driver]Cannot update the cursor
พอมีแนวทางแก้ไขไหม
Connections.asp
Class Connections
'constance
Private sPathData, sPathServer
'constructor
Public Default Function Connects(subPath, rootPath, fixPath) 'int, str,str
sPathData = "\"
sPathServer = ""
Dim loopPaht : loopPath = 0
Dim strPath : strPath = ""
if Len(Trim(fixPath)) > 0 then
sPathData = "\" & fixPath & "\"
end if
if Len(Trim(rootPath)) > 0 then
sPathServer = rootPath
end if
if subPath > 0 then
loopPath = subPath - 1
end if
For i = 0 to loopPath
strPath = strPath & "..\"
Next
sPathServer = strPath&rootPath
Set Connects = Me
End Function
'return obj oConn
Public Function OpenConn(ConnType, ConnSoure)
Dim oConn, ServerPath, MyDirectory, ChFile
'====== server on web ========
ServerPath = Server.MapPath(sPathServer)
if(Right(ConnSoure,1) <> "/" and Right(ConnSoure,1) <> "\" and Ucase(ConnType)="DBF")then
ConnSoure=ConnSoure & "\"
end if
ServerPath = ServerPath & ConnSoure
Set MyDirectory = Server.CreateObject("Scripting.FileSystemObject")
Set oConn=Server.CreateObject("ADODB.Connection")
if(Ucase(ConnType)="DBC")then
ChFile = MyDirectory.FileExists(ServerPath)
if(ChFile <> False)then
oConn.Open "DRIVER={Microsoft Visual Foxpro Driver};SourceType=DBC;EXCLUSIVE=NO;Mode=ReadWrite;SourceDB=" & ServerPath
end if
else
if(Ucase(ConnType)="DBF")then
ChFile = MyDirectory.FolderExists(ServerPath)
if(ChFile <> False)then
oConn.Open "DRIVER={Microsoft Visual Foxpro Driver};SourceType=DBF;EXCLUSIVE=NO;Mode=ReadWrite;SourceDB=" & ServerPath
end if
end if
end if
Set OpenConn = oConn
End Function
'return obj oConn
Public Function Set_conn(n, sFl, type_db)
Dim oConn
if(n <> "")then
if(Ucase(type_db)="DBF")then
Set oConn=OpenConn(type_db,sPathData & n & "\" & sFl)
end if
if(Ucase(type_db)="DBC")then
Set oConn=OpenConn(type_db,sPathData & n & "\" & sFl)
end if
else
if(Ucase(type_db)="DBF")then
Set oConn=OpenConn(type_db,sPathData & sFl)
end if
if(Ucase(type_db)="DBC")then
Set oConn=OpenConn(type_db,sPathData & sFl)
end if
end if
set Set_conn=oConn
End Function
'return obj Conn
Public Function Select_sql(strsql, oRs, oConn)
On Error Resume Next
oRs.Open strsql,oConn,1,3
set Select_sql=oRs
End Function
'/// check all Error in file
'return type true/false
Public Function Check_Conns(n, sFl, typeDb, strSql)
Dim oRs, pStatus, oConn,log : pStatus = false
if Check_conn(n, sFl, typeDb) then
set oRs = Server.CreateObject("ADODB.Recordset")
set oConn = Set_conn(n, sFl, typeDb)
pStatus = Check_sql(strSql, oRs, oConn)
end if
Check_Conns = pStatus
End Function
'////////////////////////////////////////////////////////////////// Private ////////////////////////////////////////////////////////////////
'return true/false
Private Function CheckConn(ConnType, ConnSoure)
Dim oConn, ServerPath, MyDirectory, ChFile, rConn
'====== server on web ========
ServerPath = Server.MapPath(sPathServer)
if(Right(ConnSoure,1) <> "/" and Right(ConnSoure,1) <> "\" and Ucase(ConnType)="DBF")then
ConnSoure=ConnSoure & "\"
end if
rConn = true
ServerPath = ServerPath & ConnSoure' : Response.Write ServerPath
Set MyDirectory = Server.CreateObject("Scripting.FileSystemObject")
Set oConn=Server.CreateObject("ADODB.Connection")
if(Ucase(ConnType)="DBC")then
ChFile = MyDirectory.FileExists(ServerPath)
if(ChFile = False)then
rConn = false
end if
else
if(Ucase(ConnType)="DBF")then
ChFile = MyDirectory.FolderExists(ServerPath)
if(ChFile = False)then
rConn = false
end if
end if
end if
CheckConn = rConn
End Function
'return true/false
Private Function Check_conn(n, sFl, type_db)
'On Error Resume Next
Dim rConns : rConns = true
if(n <> "")then
if(Ucase(type_db)="DBF")then
rConns=CheckConn(type_db,sPathData & n & "\" & sFl)
end if
if(Ucase(type_db)="DBC")then
rConns=CheckConn(type_db,sPathData & n & "\" & sFl)
end if
else
if(Ucase(type_db)="DBF")then
rConns=CheckConn(type_db,sPathData & sFl)
end if
if(Ucase(type_db)="DBC")then
rConns=CheckConn(type_db,sPathData & sFl)
end if
end if
Err.Clear
Check_conn=rConns
End Function
'return true/false
Private Function Check_sql(strsql, oRs, oConn)
'On Error Resume Next
Dim rStatus : rStatus = true
oRs.Open strsql,oConn,1,3
if Err.Number <> 0 then
rStatus = false
end if
oRs.Close
Err.Clear
Check_sql = rStatus
End Function
End Class
Dim oConnect : Set oConnect = (new Connections)(3,"","xxx") 'New
Update.asp
<!--#include file="../../assets/asp/Connections.asp" -->
<!--#include file="../../assets/asp/ManageData.asp" -->
<!--#include file="../../assets/asp/Tools.asp" -->
Dim oConnectx : Set oConnectx = (new Connections)(4,"","xxxx")
Dim oMg : Set oMg = (new ManageDatas)(oConnectx.Set_conn("xxxx","","DBF"))
rs = "xxxxx|" & update_command
Dim updateStatus
updateStatus = oMg.DbUpdate(rs)
rw = oTool.CreateLog("010","..\..\log", rs &" -- " & updateStatus )
response.Write updateStatus
%>
update class
Class ManageDatas
'constance
Public c
'constructor
Public Default Function ManageDb(o) 'conn, root folder, process [ table, field, value ]
Set c = o
Set ManageDb = Me
End Function
Private Function QueryCMD(s)
'On Error Resume Next
Dim e : e = False
If Session("is_admin") <> "" OR Session("is_user") <> "" Then
c.beginTrans
c.execute s
If Err.Number <> 0 Then
c.RollBackTrans
Else
c.CommitTrans
e = True
End If
End If
'rw(s)
'rw(Err.Description)
c.Close
QueryCMD = e
End Function
Public Function DbInsert(r) 'root folder, insert process[table,field,value]
Dim s, p
p = Split(r,"|")
s = "INSERT INTO " & Trim(p(0)) & " (" & Trim(p(1)) & ") VALUES(" & Trim(p(2)) & ")" ': oErr.rw(s)
DbInsert = QueryCMD(s)
End Function
Public Function DbUpdate(r)
Dim s, p
p = Split(r,"|")
s = "UPDATE " & Trim(p(0)) & " SET " & Trim(p(1))
DbUpdate = QueryCMD(s)
End Function
Public Function DbDelete(r)
Dim s, p
p = Split(r,"|")
s = "DELETE FROM " & Trim(p(0)) & " " & Trim(p(1))
DbDelete = QueryCMD(s)
End Function
Function rw(s)
Response.Write s : response.End
End Function
End Class