Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Expected statement ????????????????

Posted on 2006-04-18
12
Medium Priority
?
350 Views
Last Modified: 2012-08-14
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
%>

0
Comment
Question by:hiepbeo
  • 5
  • 3
  • 2
  • +1
12 Comments
 
LVL 17

Expert Comment

by:HuyBD
ID: 16476152
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
 

Author Comment

by:hiepbeo
ID: 16476188
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
 
LVL 55

Expert Comment

by:Ryan Chong
ID: 16476218
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 55

Expert Comment

by:Ryan Chong
ID: 16476232
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
 
LVL 17

Expert Comment

by:HuyBD
ID: 16476434
becausre Chk is recordset object so you need add set statement
Set Chk = Conn.Execute(checkbook)
0
 
LVL 8

Expert Comment

by:Leo Eikelman
ID: 16477378
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
 

Author Comment

by:hiepbeo
ID: 16477730
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
 
LVL 55

Expert Comment

by:Ryan Chong
ID: 16477803
>>if Checkbook = Book then

if Checkbox equals to "select path from tblBooks ", this will never matched...
0
 
LVL 8

Expert Comment

by:Leo Eikelman
ID: 16477811
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
 
LVL 55

Accepted Solution

by:
Ryan Chong earned 2000 total points
ID: 16477833
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
 

Author Comment

by:hiepbeo
ID: 16478192
Wonderful ! This code is working with full of its function .Thanks everybody ! Especially ryancys
0
 
LVL 55

Expert Comment

by:Ryan Chong
ID: 16478212
You're welcome, glad could make helps here, cheers
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Loops Section Overview
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question