Snitz Forums 2000
Snitz Forums 2000
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Community Forums
 Code Support: ASP (Non-Forum Related)
 Code thinks that record isn't there, but it is...
 New Topic  Topic Locked
 Printer Friendly
Next Page
Author Previous Topic Topic Next Topic
Page: of 2

eggyfarts
Junior Member

New Zealand
200 Posts

Posted - 16 October 2003 :  01:56:23  Show Profile
I am using a MS Access DB. I have the following code that gets information from a block of text, and inserts it to the DB:



<%
Set pop3 = Server.CreateObject( "JMail.POP3" )
pop3.Connect "username", "password", "server"
if pop3.count > 0 then
Set msg = pop3.Messages.item(1) 

%>
<% if msg.Subject = "Pre Defined Subject" then %>
<% BodyString=msg.Body %>
<% exttitle = exttitle+3%>
<% extref =extref%> 
<% extamount = extamount-2%> 
<% extemail=extemail%>

<%
connString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\database.mdb;"

set conn = server.createobject("adodb.connection")
conn.open connString



mySql = "Insert into TABLE (EMAIL)"
mySql = mySql & "values ('"& email &"')"

conn.execute mySql

%>
<%
Conn.close
Set conn = nothing
%>

<%pop3.DeleteSingleMessage 1%>



Now, the code in blue is actually in an include file. Basically what the above code does is extract certain valuse from an email body and put them in to a database. It all works fine, the extraction and insertion side of it. All the correct values are put in to the DB just fine. But the weird thing is, when I go to pull that info from that DB table, it cant find the records, like when executing this code: (Changed code, as i posted wrong code and error before)




<%
email = Request.Form("EMAIL")


Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\database.mdb"
strSql = "SELECT REF FROM TABLE WHERE EMAIL = '" & email & "'" 
set rs = conn.execute(strSql)
refdb = RS("REF")
response.write "auction_refdb = "

if  ref <> refdb then%>
<table>
<tr>Error! You entered incorrect information:</tr>
<tr><td>REF:</td>
<td><b><%=ref%></b></td></tr>
<tr><td>EMAIL:</td>
<td><b><%=email%></b></td></tr>
</table>

<%else%>

Other code here....



The above code gets REF and EMAIL from a form that the user enters data into, and selects REF from the DB where EMAIL = what the user put in, and compares REF from what the user enters into the form, to REF from the db, and if its correct it pulls the whole record and if not it should display an error. Now when executing the page with the above green code on it, I get this error:



buyer_emailform = someone@server.com auction_refform = 1234567

ADODB.Field error '800a0bcd'

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

/page.asp, line 56



(Line 56 is the green line in bold)

Now the funny thing is that any script I use that uses data fom that table throws up some form of error, usually the "BOF or EOF is true or the current record is empty" sorta error. But when I manually add a record to the DB, the scripts execute just fine! Now, Im guessing there is something wrong with the way I'm adding the record to the DB, as manually entered data works fine on all those scripts. Incase it helps, all the fields are set to text, except BUYER_BID, which is set to number.

Thanks in advance for any help, this problem has me stumped.

EDIT: I changed the code in green and the error I'm getting, as I had something confused with another problem. Sorry.

Edited by - eggyfarts on 17 October 2003 23:48:06

D3mon
Senior Member

United Kingdom
1685 Posts

Posted - 16 October 2003 :  03:44:04  Show Profile  Visit D3mon's Homepage
Looks like you need to define RS2 as a Recordset object.


Snitz 'Speedball' : Site Integration Mod : Friendly Registration Mod
"In war, the victorious strategist only seeks battle after the victory has been won"
Go to Top of Page

eggyfarts
Junior Member

New Zealand
200 Posts

Posted - 16 October 2003 :  04:15:52  Show Profile
No, its saying that because at the bottom I am trying to close RS2, but it hasnt opened yet because the code didn't get a chance to execute, because of a problem futher up.

EDIT: See edited post above.

Cheers,
WeeVaa.


Edited by - eggyfarts on 17 October 2003 01:02:46
Go to Top of Page

D3mon
Senior Member

United Kingdom
1685 Posts

Posted - 16 October 2003 :  04:43:44  Show Profile  Visit D3mon's Homepage
Is the green code not the only code in the script then?

Incidentally, whats with the <% %> tags opening and closing each line? Makes it very hard to read.
Any time you've got %><% (or with a linefeed between) you can delete it, as its function is nullified unless there is some HTML between them.


Snitz 'Speedball' : Site Integration Mod : Friendly Registration Mod
"In war, the victorious strategist only seeks battle after the victory has been won"
Go to Top of Page

eggyfarts
Junior Member

New Zealand
200 Posts

Posted - 17 October 2003 :  01:05:02  Show Profile
Hi,

I have changed my first post above to reflect the true problem. Sorry for being misleading, I confused myself .

Cheers,
WeeVaa.

Go to Top of Page

D3mon
Senior Member

United Kingdom
1685 Posts

Posted - 17 October 2003 :  04:26:50  Show Profile  Visit D3mon's Homepage
You must always chck before you try to access a recordset, if there is anything in it first, like this:

if not RS.EOF then
    'RS has records
else
    'RS is empty
    response.write("an error occured")
end if


Snitz 'Speedball' : Site Integration Mod : Friendly Registration Mod
"In war, the victorious strategist only seeks battle after the victory has been won"

Edited by - D3mon on 17 October 2003 04:27:17
Go to Top of Page

D3mon
Senior Member

United Kingdom
1685 Posts

Posted - 17 October 2003 :  04:29:21  Show Profile  Visit D3mon's Homepage
You'll need to add the line in red to define RS as a Recordset.

Set conn = Server.CreateObject("ADODB.Connection")
Set RS = Server.CreateObject("ADODB.Recordset")


Snitz 'Speedball' : Site Integration Mod : Friendly Registration Mod
"In war, the victorious strategist only seeks battle after the victory has been won"

Edited by - D3mon on 17 October 2003 04:31:20
Go to Top of Page

eggyfarts
Junior Member

New Zealand
200 Posts

Posted - 17 October 2003 :  06:27:01  Show Profile
I have defines RS as a Recordset, but I am still getting the error. The problem is, I can access any record just fine with the data I manually add to the DB, but when I try and access data that has been automatically added to the DB by the red and green code at the very top, I get the error. And I know the record exists, as I am copying and pasting the variables straight from a copy of the DB! I have tried everything I can think of.

Its not just this script that has problems reading records that were automatically added, others do too, but work fine on records added manually!

Cheers,
WeeVaa.

Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 17 October 2003 :  07:35:37  Show Profile
your sql is this:
strSql = "SELECT AUCTION_REF FROM TRADEME_INFO WHERE BUYER_EMAIL = '" & buyer_emailform & "'"

from the output it looks like buyer_emailform = someone@server.com

are you absolutely positive that you have a record in the database with that email address for BUYER_EMAIL?

Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~
Go to Top of Page

eggyfarts
Junior Member

New Zealand
200 Posts

Posted - 17 October 2003 :  07:38:40  Show Profile
Yes, 110% sure. It works with manually entered records, but not ones that are automatically entered. Can you see anything wrong with the red and blue code at the top, as I suspect that is the culprit.

Cheers,
WeeVaa.

Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 17 October 2003 :  07:44:16  Show Profile
are you sure it is EXACTLY that? i.e. there are no non-printable characters before or after the email address? My guess is that there is because from your code, it looks like you are extracting the email address from the position where the email address starts to the beginning of the next line, so you probably have a line break stored after the email address.

try this instead:
<% extemail=Trim(Mid(BodyString,InStr(BodyString,"mailto:")+7,emailplace))%>

Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~
Go to Top of Page

eggyfarts
Junior Member

New Zealand
200 Posts

Posted - 17 October 2003 :  07:55:42  Show Profile
. No luck. I added the trim to both the AUCTION_REF and BUYER_EMAIL bits, and it still gives me the error. I even downloaded the DB and checked that the records were there. Is there any way to display non-printable characters on all records so I can compare the manually added ones with the automatically added ones?

Cheers,
WeeVaa.

Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 17 October 2003 :  16:29:03  Show Profile
an easy way would be to grab the data from the db and then display something like:

<textarea><%=":" & rs("BUYER_EMAIL") & ":"%></textarea>

if you see an output like:
:someone@someserver.com
:

then you know there is a line break

another thing you can try is modifying your sql to:
strSql = "SELECT AUCTION_REF FROM TRADEME_INFO WHERE BUYER_EMAIL LIKE '%" & Trim(buyer_emailform) & "%'"

that will match any entry that has that email in the middle. so if one@server.com is what you are looking for, you will get matches on one@server.com or someone@server.com if they are in the database.

Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~

Edited by - Nikkol on 17 October 2003 16:31:12
Go to Top of Page

eggyfarts
Junior Member

New Zealand
200 Posts

Posted - 17 October 2003 :  17:54:40  Show Profile
OK, I tried changing it to LIKE, but it still didn't work. Anyway, I want to find the exact record, so ABC@server.com isn't the same as 123@server.com. But I did try your method above, with the text area. Guess what, for records that I manually added to the DB, I got:

:someone@server.com:

But for records that were automatically added, I got:

:person@someserver.com
:

So there is a line break in there, so how do I get rid of it before I put it into the DB?

Cheers,
WeeVaa.

Go to Top of Page

Nikkol
Forum Moderator

USA
6907 Posts

Posted - 17 October 2003 :  18:15:47  Show Profile
not sure if this will work, but you can try:

extemail = Replace(extemail,vbNewline,"")

Nikkol ~ Help Us Help You | ReadMe | 3.4.03 fixes | security fixes ~
Go to Top of Page

eggyfarts
Junior Member

New Zealand
200 Posts

Posted - 17 October 2003 :  21:06:42  Show Profile






That worked! Thanks heaps Nikkol, your a legend!

Cheers,
WeeVaa.

Go to Top of Page
Page: of 2 Previous Topic Topic Next Topic  
Next Page
 New Topic  Topic Locked
 Printer Friendly
Jump To:
Snitz Forums 2000 © 2000-2021 Snitz™ Communications Go To Top Of Page
This page was generated in 0.48 seconds. Powered By: Snitz Forums 2000 Version 3.4.07