PDA

View Full Version : Which 'expected statement', please?


SteveH
10-27-2008, 08:19 PM
Hello

I am getting the following error:

Expected statement

/NewLog/includes/dbconnection.inc, line 4

The script is:

<%
Dim adoCon

Set adoCon = Server.CreateObject("ADODB.Connection")

sConnStr = "driver={Microsoft Access Driver (*.mdb)};DBQ=D:\business\login.mdb;"

adoCon.Open sConnStr
%>

I did have the " missing, but I still get the error.

Many thanks.

Steve

rebeltech81
10-27-2008, 09:57 PM
I think the one listed "Standard Security" under ODBC on the following link will do the trick:

http://www.connectionstrings.com/?carrier=access

hinch
10-28-2008, 01:50 AM
i tend to open my access connections like this

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=" & Server.MapPath("./db.mdb")

always perfered oledb to odbc conns for some reason don't know why just have

SteveH
10-28-2008, 11:15 AM
Hello

I think I may have resolved the connection issue along the lines of my original script (sorry hinch, my server does not like this format: & Server.MapPath("./db.mdb").

Now, if I go to a file called password.asp as if I were a user trying to log-in (the entire file is a secure asp log-in with a database), I get the following error message:

ADODB.Field error '800a0bcd'

Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.

/NewLog/includes/settings.asp, line 5

Does this mean that the server is expecting to find an entry in the database (which is currently empty)?

Many thanks.

Steve

hinch
10-28-2008, 02:27 PM
most likely your not doing an if objrs.EOF check and instead just trying to compare a db field to a value when there's nothing actualy in the db field.

wrap an

if not objrs.eof then

end if

around your code after the db select and it should work

miranda
10-28-2008, 07:31 PM
Steve,

Yes that is exactly what it means. any time you see a message that says Either BOF or EOF is True that means that it cannot find what you are looking for in the table. BOF = Begin Of File EOF = End Of File

So do as Hinch says and enclose the code in an if statement

If Not oRs.EOF Then
' assign variables
End If

SteveH
10-28-2008, 08:51 PM
Thanks hinch again and Miranda

That just produces another error - I have this:

<%

Set rsGetEmail = Server.CreateObject("ADODB.Recordset")

If Not oRs.EOF Then

strSQLAdminEmail = "SELECT [siteemail], [emailserver], [register], [lostpassword], [sitename] from tblAdmin"

End if

rsGetEmail.Open strSQLAdminEmail, adoCon
vSiteEmail = rsGetEmail("siteemail")
vEmailServer = rsGetEmail("emailserver")
vRegister = rsGetEmail("register")
vLostPassword = rsGetEmail("lostpassword")
vSiteName = rsGetEmail("sitename")
Set rsGetEmail = Nothing

End If
%>

And the error I get if I click on that particular file (settings.asp) looks like this:

Expected statement

/NewLog/includes/settings.asp, line 19

End If
^


Cheers

Steve

brazenskies
10-28-2008, 10:38 PM
you only have one 'if' but you have 2 'end if'

If you want to set all those variables if 'not oRs.EOF' then remove the end if in the middle

hinch
10-28-2008, 10:55 PM
your syntax was completely wrong this should work now


<%
Set rsGetEmail = Server.CreateObject("ADODB.Recordset")



strSQLAdminEmail = "SELECT [siteemail], [emailserver], [register], [lostpassword], [sitename] from tblAdmin"
rsGetEmail.Open strSQLAdminEmail, adoCon

If Not rsGetEmail.EOF Then

vSiteEmail = rsGetEmail("siteemail")
vEmailServer = rsGetEmail("emailserver")
vRegister = rsGetEmail("register")
vLostPassword = rsGetEmail("lostpassword")
vSiteName = rsGetEmail("sitename")
Set rsGetEmail = Nothing

End If
%>

SteveH
10-29-2008, 11:34 AM
Hello

Many thanks again to you all. Yes, hinch, that basically did it. Actually, I used this which is almost the same as yours:


<%
Set rsGetEmail = Server.CreateObject("ADODB.Recordset")
strSQLAdminEmail = "SELECT [siteemail], [emailserver], [register], [lostpassword], [sitename] from tblAdmin"
rsGetEmail.Open strSQLAdminEmail, adoCon

If (rsGetEmail.EOF = True) Or (rsGetEmail.BOF = True) Then
vSiteEmail = ""
vEmailServer = ""
vRegister = ""
vLostPassword = ""
vSiteName = ""
Else
vSiteEmail = rsGetEmail("siteemail")
vEmailServer = rsGetEmail("emailserver")
vRegister = rsGetEmail("register")
vLostPassword = rsGetEmail("lostpassword")
vSiteName = rsGetEmail("sitename")
End If

Set rsGetEmail = Nothing
%>

Cheers for all your help!

Steve

hinch
10-29-2008, 11:43 AM
you don't really need the BOF since the recordset on a clean db pull is positioned at the begining anyway you only really need bof if your stepping backwords .movelast