Forum Moderators: open

Message Too Old, No Replies

Asp Code not working

code given when i run on my PC it works on web it doesn't

         

baistopgun

8:35 pm on Oct 12, 2004 (gmt 0)

10+ Year Member



Microsoft VBScript compilation error '800a0401'

Expected end of statement
Erorr in this search file name is Search.asp

<FORM action="Search_Result.asp" method=POST id=form1 name=form1>
<select name="nm">
<%
dim objConn,my_sql,Rs
my_sql="Select name from Teaching order by name"

Set objConn=Server.CreateObject("ADODB.Connection")
objConn.Open ("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("School.mdb"))

Set Rs=objConn.Execute(my_sql)
do while not Rs.EOF
Response.Write "<option value='" & Rs("Name")& "'>"
Response.Write Rs("Name")
Rs.MoveNext
loop
Rs.Close
Set objRs=nothing
objConn.close
Set objConn=nothing

%>

mattglet

9:13 pm on Oct 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Does the error provide a line number?

Do you have any IF statements on that page, or in a header/footer file?

baistopgun

9:40 pm on Oct 12, 2004 (gmt 0)

10+ Year Member



no if statements yeah it gives errors somthing like this or on this line i mean

Microsoft VBScript compilation error '800a0401'

Expected end of statement

/apspatiala/Search.asp, line 19

Response.Write ( objRs("Name") ) objRs.MoveNext
------------------------------------^
eriler it was givening error on braces which i included after response.write ok thanx in advance for lookign into the problmes

defanjos

9:50 pm on Oct 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Response.Write ( objRs("Name") ) objRs.MoveNext

You cannot have the "objRs.MoveNext" on the same line, it has to be something like this:

Response.Write objRs("Name")
objRs.MoveNext

baistopgun

9:54 pm on Oct 12, 2004 (gmt 0)

10+ Year Member



yeha i have put this on new line but it is not workign still

baistopgun

9:57 pm on Oct 12, 2004 (gmt 0)

10+ Year Member



hi its on new line like this
Response.write( objRs("name"))
objRs.MoveNext

but when run it shows on same line chek code in above post

defanjos

10:07 pm on Oct 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



First you have to fix this:
Rs.Close
Set objRs=nothing

it should be:
Rs.Close
Set Rs=nothing

Also change any other "objRS" references to "Rs"

MozMan

10:43 pm on Oct 12, 2004 (gmt 0)

10+ Year Member



Two things:

1- As mentioned earlier, you need to be consistent in what you call your recordset object. In some places you call it Rs and in some places you call it objRs. Call it one thing throughtout the file.

2- This line might be a problem:

Set Rs=objConn.Execute(my_sql)

Try this instead:
Set Rs = Server.CreateObject("ADODB.Recordset")
Rs.Open my_sql, objConn

then go into your loop.

-Moz

duckhunter

1:42 am on Oct 13, 2004 (gmt 0)

10+ Year Member



should be:
Response.write( objRs.FIELDS("name"))

[edit]or RS.Fields (which ever object name you are using[/edit]

baistopgun

4:31 am on Oct 13, 2004 (gmt 0)

10+ Year Member



i have fixed all error but it is not workign yet hey i have replaced that objRs with RS i have wriiten previous version of code in query i guess ghere is new one still it is not workign
*****************************************
when i run the code on my ho0me pc it works fine but when i upload the same file it gives this error io could nto get it why plz help
Microsoft VBScript compilation error '800a0401'
Expected end of statement
Erorr in this search file name is Search.asp

<FORM action="Search_Result.asp" method=POST id=form1 name=form1>
<select name="nm">
<%
dim objConn,my_sql,objRs
my_sql="Select name from Teaching order by name"

Set objConn=Server.CreateObject("ADODB.Connection")
objConn.Open ("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" & Server.MapPath("School.mdb"))

Set objRs=objConn.Execute(my_sql)
do while not objRs.EOF
Response.Write "<option value='" & objRs("Name")& "'>"
Response.Write objRs("Name")
objRs.MoveNext
loop
objRs.Close
Set objRs=nothing
objConn.close
Set objConn=nothing

%>

no if statements yeah it gives errors somthing like this or on this line i mean
Microsoft VBScript compilation error '800a0401'

Expected end of statement

Search.asp, line 19

Response.Write ( objRs("Name") ) objRs.MoveNext
------------------------------------^
eriler it was givening error on braces which i included after response.write ok thanx in advance for lookign into the problmes

duckhunter

1:37 pm on Oct 13, 2004 (gmt 0)

10+ Year Member



objRs.MoveNext should not be showing up on the same line.

Make sure there is a valid Carriage Return there

baistopgun

5:17 pm on Oct 13, 2004 (gmt 0)

10+ Year Member



thanks all this problem is sloved hey no problems with code but problem in carrige return onlyyyyyyyyy thanx anywayzzzzzzzzzzzzz