hiepbeo
asked on
Expected statement ????????????????
I have a question . I think syntax is good !
I don't know why i get this error ????
Error Type:
Microsoft VBScript compilation (0x800A0400)
Expected statement
/web/code/xulythemsach.asp , line 15
End if
Here is code:
<%
strconn = "Provider = Microsoft.Jet.OleDB.4.0; Data Source =" & Server.MapPath("../assets/ data.mdb") & ";"
set conn = Server.CreateObject("ADODB .Connectio n") ' connect
set rs = Server.CreateObject("ADODB .RecordSet ") 'RecordSet
'Mo ket noi voi CSDL
conn.Open Strconn
Dim Book
Dim checkbook
book = request.Form("taifile")
Id = request("id")
checkbook = "select path from tblBooks "
Chk = Conn.Execute(checkbook)
Do until chk.EOF
if Checkbook = Book then response.redirect"themsach .asp?error =Exists!"
End if (line 15)
chk.movenext
loop
strSQL = "INSERT INTO tblBooks(name,lang,path,fo rmat,autho r,publishi ng,imgpath ,keywords) values('" & request.Form("Tensach") & "', '" & request.Form("ngonngu") & "','" & request.Form("taifile") & "','" & request.Form("loaifile") & "','" & request.Form("txttg") & "','" & request.Form("txtnxb") & "','" & request.Form("anh") & "','" & request.Form("Tukhoa") & "')"
Set RS = Conn.Execute(strSQL)
set RS = nothing
%>
I don't know why i get this error ????
Error Type:
Microsoft VBScript compilation (0x800A0400)
Expected statement
/web/code/xulythemsach.asp
End if
Here is code:
<%
strconn = "Provider = Microsoft.Jet.OleDB.4.0; Data Source =" & Server.MapPath("../assets/
set conn = Server.CreateObject("ADODB
set rs = Server.CreateObject("ADODB
'Mo ket noi voi CSDL
conn.Open Strconn
Dim Book
Dim checkbook
book = request.Form("taifile")
Id = request("id")
checkbook = "select path from tblBooks "
Chk = Conn.Execute(checkbook)
Do until chk.EOF
if Checkbook = Book then response.redirect"themsach
End if (line 15)
chk.movenext
loop
strSQL = "INSERT INTO tblBooks(name,lang,path,fo
Set RS = Conn.Execute(strSQL)
set RS = nothing
%>
ASKER
Another error here. (I followed your support)
Error Type:
Microsoft VBScript runtime (0x800A01B6)
Object doesn't support this property or method: 'Chk.EOF'
/web/code/xulythemsach.asp , line 14
Error Type:
Microsoft VBScript runtime (0x800A01B6)
Object doesn't support this property or method: 'Chk.EOF'
/web/code/xulythemsach.asp
something like this.. ?
<%
strconn = "Provider = Microsoft.Jet.OleDB.4.0; Data Source =" & Server.MapPath("../assets/ data.mdb") & ";"
set conn = Server.CreateObject("ADODB .Connectio n") ' connect
set rs = Server.CreateObject("ADODB .RecordSet ") 'RecordSet
'Mo ket noi voi CSDL
conn.Open Strconn
Dim Book
Dim checkbook
book = request.Form("taifile")
Id = request("id")
checkbook = "select path from tblBooks "
rs.open checkbook, Conn, 1, 1
Do while rs.EOF = false
if Checkbook = Book then
response.redirect"themsach .asp?error =Exists!"
End if
rs.movenext
loop
strSQL = "INSERT INTO tblBooks(name,lang,path,fo rmat,autho r,publishi ng,imgpath ,keywords) values('" & request.Form("Tensach") & "', '" & request.Form("ngonngu") & "','" & request.Form("taifile") & "','" & request.Form("loaifile") & "','" & request.Form("txttg") & "','" & request.Form("txtnxb") & "','" & request.Form("anh") & "','" & request.Form("Tukhoa") & "')"
Set RS = Conn.Execute(strSQL)
set RS = nothing
%>
<%
strconn = "Provider = Microsoft.Jet.OleDB.4.0; Data Source =" & Server.MapPath("../assets/
set conn = Server.CreateObject("ADODB
set rs = Server.CreateObject("ADODB
'Mo ket noi voi CSDL
conn.Open Strconn
Dim Book
Dim checkbook
book = request.Form("taifile")
Id = request("id")
checkbook = "select path from tblBooks "
rs.open checkbook, Conn, 1, 1
Do while rs.EOF = false
if Checkbook = Book then
response.redirect"themsach
End if
rs.movenext
loop
strSQL = "INSERT INTO tblBooks(name,lang,path,fo
Set RS = Conn.Execute(strSQL)
set RS = nothing
%>
strSQL = "INSERT INTO tblBooks(name,lang,path,fo rmat,autho r,publishi ng,imgpath ,keywords) values('" & request.Form("Tensach") & "', '" & request.Form("ngonngu") & "','" & request.Form("taifile") & "','" & request.Form("loaifile") & "','" & request.Form("txttg") & "','" & request.Form("txtnxb") & "','" & request.Form("anh") & "','" & request.Form("Tukhoa") & "')"
Set RS = Conn.Execute(strSQL)
set RS = nothing
should be as:
strSQL = "INSERT INTO tblBooks(name,lang,path,fo rmat,autho r,publishi ng,imgpath ,keywords) values('" & request.Form("Tensach") & "', '" & request.Form("ngonngu") & "','" & request.Form("taifile") & "','" & request.Form("loaifile") & "','" & request.Form("txttg") & "','" & request.Form("txtnxb") & "','" & request.Form("anh") & "','" & request.Form("Tukhoa") & "')"
Conn.Execute(strSQL)
Rs.Close
set RS = nothing
'Conn.close
'set conn = nothing
...
Set RS = Conn.Execute(strSQL)
set RS = nothing
should be as:
strSQL = "INSERT INTO tblBooks(name,lang,path,fo
Conn.Execute(strSQL)
Rs.Close
set RS = nothing
'Conn.close
'set conn = nothing
...
becausre Chk is recordset object so you need add set statement
Set Chk = Conn.Execute(checkbook)
Set Chk = Conn.Execute(checkbook)
You specified rs as a recordset so why are u usign Chk as a recordset?
get rid of this line
Chk = Conn.Execute(checkbook)
and replace it with
rs.open checkbook, conn
then isntead of
chk.EOF do rs.EOF
Leo
get rid of this line
Chk = Conn.Execute(checkbook)
and replace it with
rs.open checkbook, conn
then isntead of
chk.EOF do rs.EOF
Leo
ASKER
Hi everybody ! Thanks for your immediate response. Now it worked, but it doesn't work as i think. I want to compare between 2 value, the first is the value book we can request from text box "taifile". The second is taken from the columns path form database. If 2 value is equal, display "Error!". If not, we will insert info into database. This code is work with no error. But when i try to insert the two value which is the same, all are inserted into database.
here: http://www.eric.trada.us/trung.jpg
WHY ?? Hope that everybody will solve this problem for me. Thanks!
Here are the code (server php,so you can access it as text file):
http://www.eric.trada.us/themsach.asp
http://www.eric.trada.us/xulythemsach.asp
In brief:
file processsearch.asp
<%
strconn = "Provider = Microsoft.Jet.OleDB.4.0; Data Source =" & Server.MapPath("../assets/ data.mdb") & ";"
set conn = Server.CreateObject("ADODB .Connectio n") ' connect
set rs = Server.CreateObject("ADODB .RecordSet ") 'RecordSet
'Mo ket noi voi CSDL
conn.Open Strconn
Dim Book
Dim checkbook
book = request.Form("taifile")
Id = request("id")
checkbook = "select path from tblBooks "
rs.open checkbook, Conn, 1, 1
Set Chk = Conn.Execute(checkbook)
Do while rs.EOF = false
if Checkbook = Book then
response.redirect"themsach .asp?error =Sách đã có trong thư viện. Xin vui lòng nhập sách khác!"
End if
rs.movenext
loop
strSQL = "INSERT INTO tblBooks(name,lang,path,fo rmat,autho r,publishi ng,imgpath ,keywords) values('" & request.Form("Tensach") & "', '" & request.Form("ngonngu") & "','" & request.Form("taifile") & "','" & request.Form("loaifile") & "','" & request.Form("txttg") & "','" & request.Form("txtnxb") & "','" & request.Form("anh") & "','" & request.Form("Tukhoa") & "')"
Conn.Execute(strSQL)
Rs.Close
set RS = nothing
'Conn.close
'set conn = nothing
%>
here: http://www.eric.trada.us/trung.jpg
WHY ?? Hope that everybody will solve this problem for me. Thanks!
Here are the code (server php,so you can access it as text file):
http://www.eric.trada.us/themsach.asp
http://www.eric.trada.us/xulythemsach.asp
In brief:
file processsearch.asp
<%
strconn = "Provider = Microsoft.Jet.OleDB.4.0; Data Source =" & Server.MapPath("../assets/
set conn = Server.CreateObject("ADODB
set rs = Server.CreateObject("ADODB
'Mo ket noi voi CSDL
conn.Open Strconn
Dim Book
Dim checkbook
book = request.Form("taifile")
Id = request("id")
checkbook = "select path from tblBooks "
rs.open checkbook, Conn, 1, 1
Set Chk = Conn.Execute(checkbook)
Do while rs.EOF = false
if Checkbook = Book then
response.redirect"themsach
End if
rs.movenext
loop
strSQL = "INSERT INTO tblBooks(name,lang,path,fo
Conn.Execute(strSQL)
Rs.Close
set RS = nothing
'Conn.close
'set conn = nothing
%>
>>if Checkbook = Book then
if Checkbox equals to "select path from tblBooks ", this will never matched...
if Checkbox equals to "select path from tblBooks ", this will never matched...
obviously this check, Checkbook = Book is not working correctly
print out the values of Checkbook and book before the line
Checkbook = Book and see what they are.
you can also try
if Trim(checkBook) = Trim(book) then
etc.
Leo
print out the values of Checkbook and book before the line
Checkbook = Book and see what they are.
you can also try
if Trim(checkBook) = Trim(book) then
etc.
Leo
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Wonderful ! This code is working with full of its function .Thanks everybody ! Especially ryancys
You're welcome, glad could make helps here, cheers
Do until chk.EOF
if Checkbook = Book then
response.redirect"themsach
End if
chk.movenext
loop