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.Connection")        ' 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,format,author,publishing,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
%>

hiepbeoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HuyBDCommented:
Just for ASP proccessing, you must breaking in line 14

Do until chk.EOF
     if Checkbook = Book then
          response.redirect"themsach.asp?error=Exists!"
     End if
chk.movenext
loop
0
hiepbeoAuthor Commented:
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
0
Ryan ChongCommented:
something like this.. ?


<%
strconn = "Provider = Microsoft.Jet.OleDB.4.0; Data Source =" & Server.MapPath("../assets/data.mdb") & ";"
set conn = Server.CreateObject("ADODB.Connection")       ' 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,format,author,publishing,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
%>
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Ryan ChongCommented:
strSQL = "INSERT INTO tblBooks(name,lang,path,format,author,publishing,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,format,author,publishing,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
...
0
HuyBDCommented:
becausre Chk is recordset object so you need add set statement
Set Chk = Conn.Execute(checkbook)
0
Leo EikelmanDirector, IT and Business DevelopmentCommented:
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
0
hiepbeoAuthor Commented:
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.Connection")       ' 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 &#273;ã có trong th&#432; vi&#7879;n. Xin vui lòng nh&#7853;p sách khác!"
     End if
   rs.movenext
loop
 strSQL = "INSERT INTO tblBooks(name,lang,path,format,author,publishing,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
%>
0
Ryan ChongCommented:
>>if Checkbook = Book then

if Checkbox equals to "select path from tblBooks ", this will never matched...
0
Leo EikelmanDirector, IT and Business DevelopmentCommented:
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
0
Ryan ChongCommented:
try this maybe:

<%
strconn = "Provider = Microsoft.Jet.OleDB.4.0; Data Source =" & Server.MapPath("../assets/data.mdb") & ";"
set conn = Server.CreateObject("ADODB.Connection")       ' 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 Where path = '" & replace(book, "'", "''") & "' "
rs.open checkbook, Conn, 1, 1

If rs.EOF Then
       strSQL = "INSERT INTO tblBooks(name,lang,path,format,author,publishing,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)
else
        response.write "Error!"
end if

Rs.Close
set RS = nothing
'Conn.close
'set conn = nothing
%>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hiepbeoAuthor Commented:
Wonderful ! This code is working with full of its function .Thanks everybody ! Especially ryancys
0
Ryan ChongCommented:
You're welcome, glad could make helps here, cheers
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.