asp add new record, VB, access

liunx

Guest
ok im a code re-user and i went to reuse this code and it won't work for the life of me. its worked for like 5 months previous. I checked for reserved jet words, and done everything else i can think of. anyone see anything?

also i just installed the .net framework and sdk could that be the reason?

its not throwing an error but when i go and view the page source it stopped parsing somewhere b/t the body tags cause the closing body tag isn't there.

odd.

code
=============================================


<%

Dim strFileName, strConnect, strFileType, strStickiness, strCategory, strProjectID

strFileName = Request.Form("fFile")
strFileType = Request.Form("fFileType")
strCategory = Request.Form("fCategory")
strStickiness = Request.Form("fStickiness")
strProjectID = Request.Form("fProjectID")

strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=c:\Inetpub\wwwroot\Luminopolis\DB\Luminopolis.mdb;" & "Persist Security Info=False"

Dim objRS
Set objRS = Server.CreateObject ("ADODB.Recordset")

objRS.Open "eGallery", strConnect, adLockOptimistic

objRS.AddNew
objRS("dbFileName") = strFileName
objRS("dbFileType") = strFileType
objRS("dbStickiness") = strStickiness
objRS("dbCategory") = strCategory
objRS("dbProjectID") = strProjectID
objRS.Update
objRS.Close

objRS.Open "SELECT dbFileName FROM eGallery WHERE dbID=" & intIDForNewRecord, strConnect, adOpenForwardOnly, adLockReadOnly, adCmdText

If objRS.EOF Then
Response.Write "New record not found - Please Try again"
Else
%>

<br /><br /><br /><br /><br /><br /><br /><br />
You've sucessfully added this image:<br /><%=objRS("dbFileName")%>.<%=objRS("dbFileType")%><br /><br />




<%
End If

objRS.Close
Set objRS = Nothing
%>

========================================

Thanks,I can't see anything obviously wrong with the code and it seems strange that you don't get any error message at all. Do you have any javascript running on the same page?

When you do view source, what do the last few lines of code say before it stops?

I don't think it has anything to do with the .NET Framework being installed, as far as I know it can sit happily side by side with ASP.yeah thats what i thought too. (ive had the .net before w/ no problem)

this is what the source looks when i view the blank page.



<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">


<head>
<title></title>

<META NAME="Author" CONTENT="?">
<META NAME="Keywords" CONTENT="?">
<META NAME="Description" CONTENT="?">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body{font-family:verdana;font-size:9px;}
//-->
</style>
</head>
<body>


__________________________________-


Also i played w/ a response.write "something" and it would show up until i put it after the objRS.open .

also i'm using no javascript whatsoever.

?????????The last time you used this code, were you using an Access database? The only time I have used the .AddNew method was with an Oracle database and I'm not sure if it works with the type of connection you are using. With Access I normally use the SQL INSERT statement. See here: <!-- m --><a class="postlink" href="http://www.w3schools.com/sql/sql_insert.asp">http://www.w3schools.com/sql/sql_insert.asp</a><!-- m -->

You could try doing it that way instead and see what happens.is there anyway i could get you to post some more of your code using that method? Maybe a full add record page?

thanks,Well, I'm at home at the moment so I don't have any of my code to hand but I'll have a go at rewriting your code using the method I normally use:


strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=c:\Inetpub\wwwroot\Luminopolis\DB\Luminopolis.mdb;" & "Persist Security Info=False"

SQL = "INSERT INTO eGallery (dbFileName, dbFileType, dbStickiness, dbCategory, dbProjectID) VALUES ('" & strFileName & "', '" & strFileType & "', '" & strStickiness & "', '" & strCategory & "', '" & strProjectID
& "')"

strConnect.Execute(SQL)



That's the part of code that inserts the new record anyway, I hope that's right. Let me know if you get any errors and hopefully I'll recognise them and we can fix them. Also, you may or may not need single quotes around those values being inserted depending on what your database field types are. If you get any type mismatch errors then check those.

Hope that helps, let me know how you get on. ;)thanks goldi

but still the same ol same ol.

this is what i've got now
<%

Dim strFileName, strConnect, strFileType, strStickiness, strCategory, strProjectID

strFileName = Request.Form("fFile")
strFileType = Request.Form("fFileType")
strCategory = Request.Form("fCategory")
strStickiness = Request.Form("fStickiness")
strProjectID = Request.Form("fProjectID")


strConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=c:\Inetpub\wwwroot\Luminopolis\DB\Luminopolis.mdb;" & "Persist Security Info=False"

SQL = "INSERT INTO eGallery (dbFileName, dbFileType, dbStickiness, dbCategory, dbProjectID) VALUES ('" & strFileName & "', '" & strFileType & "', '" & strStickiness & "', '" & strCategory & "', '" & strProjectID & "')"

strConnect.Execute(SQL)

objRS.Close
Set objRS = Nothing
%>


do i need the objRS.close?

i guess i'll change all the variable names and see if that changes anything.


flabbergasted :eek:


thank you,Wow, what a weird problem! :confused: I don't see why your variable names should be a problem, they look ok to me. The weirdest thing is that you aren't getting any kind of error. At least if we had one of those we would know where to begin! :(

Yes you do need the objRS.close by the way.

Hopefully someone else can help with this, I'll keep thinking in the mean time.thanks goldilocks,

i really appreciate all your help. what i'll probally try doing next is changing all the paths and uploading to see if i can get an error.I do not see a Connection.Open statement in what you provided.ok so my brain hurts now but i managed to work some kinks out. I've now got:





<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<head>
<title></title>
<!-- METADATA TYPE="typelib"
File="C:\Program Files\Common Files\System\ado\msado15.dll" -->
<META NAME="Author" CONTENT="?">
<META NAME="Keywords" CONTENT="?">
<META NAME="Description" CONTENT="?">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body{font-family:verdana;font-size:9px;}
//-->
</style>
</head>
<body>
<%

Dim strFileName, strConnect, strFileType, strStickiness, strCategory, strProjectID

strFileName = Request.Form("fFile")
strFileType = Request.Form("fFileType")
strCategory = Request.Form("fCategory")
strStickiness = Request.Form("fStickiness")
strProjectID = Request.Form("fProjectID")

Dim objRS, objConn
Set objRS = Server.CreateObject("ADODB.Recordset")
Set objConn = Server.CreateObject("ADODB.Connection")

objConn.open = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=C:\Domains\weareluminopolis.com\db\Luminopolis.mdb;" & "Persist Security Info=False"

strSQL = "SELECT * FROM eGallery WHERE dbID=0"
objRS.Open strSQL, objConn, 2, 2
objRS.AddNew
objRS("dbFileName") = strFileName
objRS("dbFileType") = strFileType
objRS("dbStickiness") = strStickiness
objRS("dbCategory") = strCategory
objRS("dbProjectID") = strProjectID
objRS.Update

%>

<br /><br /><br /><br /><br /><br /><br /><br />
You've sucessfully added this image:<br /><%=objRS("dbFileName")%>.<%=objRS("dbFileType")%><br /><br />

<%

objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
%>
</body>
</html>

______________________________________________

which is producing this:
ADODB.Recordset error '800a0cc1'
Item cannot be found in the collection corresponding to the requested name or ordinal.

on line 47 which is:
objRS("dbProjectID") = strProjectID


Usually its a spelling mistake w/ this error but this time apparently its not.

thanks,your correct with usually being the issue

I thought the same thing the other day. But found that I mis-spelled the word in the db.it was a space in a name.

thanks for everyones help again.
im sure ill see you all very soon.
 
Back
Top