If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Why the data doesn't get written into my Access Database?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-19-02, 04:42
LINDA LINDA is offline
Registered User
 
Join Date: Dec 2002
Posts: 2
Unhappy Why the data doesn't get written into my Access Database?

I know I may be asking a very entry level question, but please help me out here. I am just starting to learn ASP and I am having a hard time figuring out why the data I enter on my webform does not get written into my Access database. I know there must be something I did wrong. I really appreciate your help, whoever you are, thank you from my heart!

Below is the asp form I wrote. There are total 5 fields where people simply enter information on the webform and the information should get written into my Access database. I think there is something wrong with line 10 & 11..... Can someone help me to see what problem I have?

-----------------------------------------------------------------------
<%
form_MemberID = Request.Form("MemberID")
form_MemName = Request.Form("MemName")
form_ReplyEMail = Request.Form("ReplyEMail")
form_InqType = Request.Form("InqType")
form_InqContent = Request.Form("InqContent")

Set db = Server.CreateObject("ADODB.Connection")
db.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & Server.MapPath("Data\CBFG.mdb") & "'"

Set rs = Server.CreateObject( "ADODB.Recordset" )
rs.open "SELECT * FROM tblVIP WHERE MemberID='" & form_MemberID & "'", db, 3, 3

if rs.bof and rs.eof then
rs.addnew
rs("eDateTime") = Now() 'Date/Time 8
rs("MemberID") = form_MemberID 'Text 10
rs("MemName") = form_MemName 'Text 20
rs("ReplyEMail") = form_ReplyEMail 'Text 30
rs("InqType") = form_InqType 'Text 15
rs("InqContent") = form_InqContent 'Note
rs.update
end if

rs.close
Set rs = Nothing
db.close
Set db = Nothing

Response.Redirect "thankyou.asp"

%>
Reply With Quote
  #2 (permalink)  
Old 12-19-02, 10:02
ismfa ismfa is offline
Registered User
 
Join Date: Dec 2002
Location: Ireland
Posts: 4
Try this

I have renamed some of the variables to ones that I am used to working with. Check out 4guysfromrolla.com they have excellent tips. Anyting else let me know.
<%option explicit%>
<%
DIM form_MemberID
DIM form_MemName
DIM form_ReplyEMail
DIM form_InqType
DIM form_InqContent
DIM straccessdb 'holds the database path and name
DIM Conn 'holds the connection
DIM rs 'holds the recordset info
DIM strdatetime
DIM strsql

form_MemberID = "abcd" 'Request.Form("MemberID")
form_MemName = "Arnold" 'Request.Form("MemName")
form_ReplyEMail = "arnold@ismfa.com" 'Request.Form("ReplyEMail")
form_InqType = "help" 'Request.Form("InqType")
form_InqContent = "i cant dp it" 'Request.Form("InqContent")
strdatetime = now()

straccessdb = "/Data/CBFG.mdb" 'you had the / the wrong way around
Set Conn = Server.CreateObject("ADODB.Connection")
Set Rs = Server.CreateObject("ADODB.Recordset")
Conn.Open "DRIVER={Microsoft Access Driver (*.mdb)};uid=;pwd=; DBQ=" & Server.MapPath(strAccessdb)

'I assume that you have this here so that the same member id cannot post more than once??
rs.open "SELECT * FROM tblVIP WHERE MemberID = '" & form_MemberID & "'", conn

'if the recordset is empty then insert the values
if rs.bof and rs.eof then
rs.close
strSQL = "INSERT INTO tblvip "
strSQL = strSQL & "(eDateTime, MemberID, MemName, ReplyEMail, InqType, InqContent) VALUES"
strSQL = strSQL & "('" & strdatetime & "','" & form_MemberID & "','" & form_MemName & "','" & form_ReplyEMail & "','" & form_InqType & "','" & form_InqContent & "')"

Rs.Open strSQL, Conn
end if


Set rs = Nothing
conn.close
Set conn = Nothing

Response.Redirect "thankyou.asp"

%>
Reply With Quote
  #3 (permalink)  
Old 12-22-02, 20:38
LINDA LINDA is offline
Registered User
 
Join Date: Dec 2002
Posts: 2
Angry It requires OLEDB

Hi, thank you for your kind help. I really really appreciate. I tried to use your method but it didn't work because my ISP doesn't support anything else other than OLEDB. I am not very familiar with OLEDB, so still trying to figure out the solution. Do you know anything about OLEDB? Thanks for your help anyway.
Reply With Quote
  #4 (permalink)  
Old 12-28-02, 12:10
D-Swing D-Swing is offline
Junior Member
 
Join Date: Dec 2002
Posts: 2
Lightbulb Any ideas?

I'm also having problems entering data into my access db. I'm running this through a local page using IIS. (hope that made sense)
My code and error:
--------------------------------------
<%@ Language = "VBScript"%>
<%
dim conn
dim rs
dim strSQL
dim strconn

strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("/board.mdb")

strSQL = "INSERT INTO Message (Name, MessageR) Values ('" & request("T1") & "', '" & request("S1") & "')"

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

conn.execute(strSQL)
conn.close
set conn = nothing
%>

-------------------
Error:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.
/process.asp, line 15 'line 15 is "conn.execute(strSQL)"


-----
Any help would be great! Thanks
Reply With Quote
  #5 (permalink)  
Old 12-30-02, 06:13
sk8te sk8te is offline
Registered User
 
Join Date: Dec 2002
Posts: 4
Wink

Maybe you can try this if you testing on your local machine. Set the access level of the folder at which your access DB is stored to allow access to everyone. Hope this will help....maybe you can post the error message?
Reply With Quote
  #6 (permalink)  
Old 12-31-02, 11:07
rnealejr rnealejr is offline
Registered User
 
Join Date: Feb 2002
Posts: 2,232
Make sure that the iusr account (or the account that is used for anonymous access) has access to the folder and mdb file and that the database permissions are set correctly. Is this database located on the same machine as iis ?
Reply With Quote
  #7 (permalink)  
Old 12-31-02, 11:09
rnealejr rnealejr is offline
Registered User
 
Join Date: Feb 2002
Posts: 2,232
I just did a quick search and found the following article - take a look:

article
Reply With Quote
  #8 (permalink)  
Old 01-02-03, 22:59
D-Swing D-Swing is offline
Junior Member
 
Join Date: Dec 2002
Posts: 2
Lightbulb Thanks

Thanks for your help guys, I looked at the article and tried their solutions but none of them worked.

Maybe it has something to do with Win XP ..
Well I've all but given up on this, how do you guys enter data into a Access db through asp?

rnealejr: Yes, it's on the same machine as iis.
Reply With Quote
  #9 (permalink)  
Old 01-02-03, 23:07
sk8te sk8te is offline
Registered User
 
Join Date: Dec 2002
Posts: 4
Talking

dun mind me asking... but where did you set the access level of the DB or even the folder holding the DB? It should be set outside of IIS, within windoze itself....also did you set the access properties on IIS??

I understand how you feel as I was stuck with that problem for 3 days... and cannot sleep because of that...hahah

Nonetheless maybe you can try your DB and script on another machine? I tested mine on my web hoster and it worked there...thats when I know something was wrong with my server...

HAPPY NEW YEAR!!!
Reply With Quote
  #10 (permalink)  
Old 02-05-03, 17:15
0r8it 0r8it is offline
Registered User
 
Join Date: Feb 2003
Posts: 1
Hmm. I'm making these assumptions:
-WinXP
_NTFS drive (probably)
-IIS
-Inetpub\wwwroot directory
-a subfolder within this.

Try this:

*Rightclick on the SPECIFIC folder your files are in; ie, if you've created
a subdir called "linda" that contains the files, then RC on this
*Select Properties, then General.
*ensure Read-only is unticked- select option to apply this to subfolders and files.
*Select WebSharing tab- "Share this folder", and edit the permissions to the way you want; I normally tick everything.

Generally, this seems to be a problem with XP (NT) and permissions.

0r8it
Reply With Quote
  #11 (permalink)  
Old 02-10-03, 05:50
vineetall vineetall is offline
Registered User
 
Join Date: Feb 2003
Posts: 11
Thumbs up Re: Any ideas?

Hi This message clearly indicates that your database is read only. You can make a copy of the tables in other database and try or make your existing database editable

Quote:
Originally posted by D-Swing
I'm also having problems entering data into my access db. I'm running this through a local page using IIS. (hope that made sense)
My code and error:
--------------------------------------
<%@ Language = "VBScript"%>
<%
dim conn
dim rs
dim strSQL
dim strconn

strconn = "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("/board.mdb")

strSQL = "INSERT INTO Message (Name, MessageR) Values ('" & request("T1") & "', '" & request("S1") & "')"

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

conn.execute(strSQL)
conn.close
set conn = nothing
%>

-------------------
Error:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC Microsoft Access Driver] Operation must use an updateable query.
/process.asp, line 15 'line 15 is "conn.execute(strSQL)"


-----
Any help would be great! Thanks
Reply With Quote
  #12 (permalink)  
Old 02-10-03, 05:54
vineetall vineetall is offline
Registered User
 
Join Date: Feb 2003
Posts: 11
Re: Why the data doesn't get written into my Access Database?

Hi to my knowledge to insert datatime values in access you need to use # around them e.g. #12/12/2002# it donot works in normal single quotes way. Moreover check whether your database is updateable or not.Moreover user 1,3,2 in rs .open in last instead of 3,3


Quote:
Originally posted by LINDA
I know I may be asking a very entry level question, but please help me out here. I am just starting to learn ASP and I am having a hard time figuring out why the data I enter on my webform does not get written into my Access database. I know there must be something I did wrong. I really appreciate your help, whoever you are, thank you from my heart!

Below is the asp form I wrote. There are total 5 fields where people simply enter information on the webform and the information should get written into my Access database. I think there is something wrong with line 10 & 11..... Can someone help me to see what problem I have?

-----------------------------------------------------------------------
<%
form_MemberID = Request.Form("MemberID")
form_MemName = Request.Form("MemName")
form_ReplyEMail = Request.Form("ReplyEMail")
form_InqType = Request.Form("InqType")
form_InqContent = Request.Form("InqContent")

Set db = Server.CreateObject("ADODB.Connection")
db.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" & Server.MapPath("Data\CBFG.mdb") & "'"

Set rs = Server.CreateObject( "ADODB.Recordset" )
rs.open "SELECT * FROM tblVIP WHERE MemberID='" & form_MemberID & "'", db, 3, 3

if rs.bof and rs.eof then
rs.addnew
rs("eDateTime") = Now() 'Date/Time 8
rs("MemberID") = form_MemberID 'Text 10
rs("MemName") = form_MemName 'Text 20
rs("ReplyEMail") = form_ReplyEMail 'Text 30
rs("InqType") = form_InqType 'Text 15
rs("InqContent") = form_InqContent 'Note
rs.update
end if

rs.close
Set rs = Nothing
db.close
Set db = Nothing

Response.Redirect "thankyou.asp"

%>
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On