Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing on an access database

Status
Not open for further replies.

jpinto

Technical User
Dec 12, 2003
75
PT
I've the following code:
Code:
<%
 Dim cnnSimple  ' ADO connection
 Dim rstSimple  ' ADO recordset
 Dim strDBPath  ' path to our Access database (*.mdb) file
 Dim MySQL 
 Dim source
 strDBPath = Server.MapPath("db/rssdb.mdb")
 Set cnnSimple = Server.CreateObject("ADODB.Connection")
 cnnSimple.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & ";"
 Set rstSimple = Server.CreateObject("ADODB.Recordset")
 MySQL = "SELECT * FROM news"
 source = "The New York Times"
 rstSimple.Open MySQL, cnnSimple,3,3
 URLToRSS = "[URL unfurl="true"]http://www.nytimes.com/services/xml/rss/nyt/HomePage.xml"[/URL]	
 MaxNumberOfItems = 50
 MainTemplateHeader = "<table>"
 MainTemplateFooter = "</table>"
 ItemTemplate = "<tr><td><a href=" & """{LINK}""" & ">{TITLE}</a><BR>{DESCRIPTION}</td></tr>"
 ErrorMessage = "No news available!"
 Set xmlHttp = Server.CreateObject("MSXML2.XMLHTTP.3.0")
 xmlHttp.Open "Get", URLToRSS, false
 xmlHttp.Send()
 RSSXML = xmlHttp.ResponseText
 Set xmlDOM = Server.CreateObject("MSXML2.DomDocument.3.0")
 xmlDOM.async = false
 xmlDOM.LoadXml(RSSXML)
 Set xmlHttp = Nothing
 Set RSSItems = xmlDOM.getElementsByTagName("item")
 Set xmlDOM = Nothing
 RSSItemsCount = RSSItems.Length-1
 if RSSItemsCount > 0 then 
 	Response.Write MainTemplateHeader
 End If
 j = -1
 For i = 0 To RSSItemsCount
 	rstSimple.AddNew
 	Set RSSItem = RSSItems.Item(i)
  	for each child in RSSItem.childNodes
   		Select case lcase(child.nodeName)
     		case "title"
           		RSStitle = child.text
     		case "link"
           		RSSlink = child.text
	 		case "description"
           		RSSdescription = child.text
	 		case "pubDate"
           		RSSpubdate = child.text
   		End Select
		rstSimple.Fields("Source")  = source
		rstSimple.Fields("Headline")  = RSSTitle
    	rstSimple.Fields("Description")  = RSSDescription
    	rstSimple.Fields("Link")  = RSSlink
		rstSimple.Fields("Date")  = RSSpubdate
		rstSimple.Update
		rstSimple.Close
		Set rstSimple = Nothing
  	next
  	j = J+1
  	if J<MaxNumberOfItems then

		%>
		<img src="/images/arrow.gif" width="14" height="9" align="middle"><a href="<%= RSSlink%>" target="_blank" class="hyperblue" onMouseOver="window.status='More...';return true;" onMouseOut="window.status='';return true;"><%= RSSTitle%></a><br> <div align="justify"><a class="black"><%= RSSDescription%></a></div>
    	<br class="smallblack"> <% ItemContent = ""
  	End if
 Next
 Set cnnSimple = Nothing
 cnnSimple.Close
 if RSSItemsCount > 0 then 
  Response.Write MainTemplateFooter
 else 
  Response.Write ErrorMessage
 End If %>

When I try to write to the access database I get an error message from my server:

"Current_Recordset_does_not_support_updating._This_may_be_a_limitation_of_the_provider__or_of_the_selected_locktype"

What can be the problem? I've checked and I've write permissions on the server for the database!

Thanks in advance for your help.

João Pinto
 
well your locktype is 3 so um, optimistic should be fine.

Try setting the cursorlocation property to client...

Also please explain this:
I've checked and I've write permissions on the server for the database!
Do you mean the file-system permissions on the .MDB file and folder that contains it or the IIS permissions? Or both?
 
Sheco,

Thanks for your quick answer.

The ISP that I've for hosting my web page says that I've write permissions on the folder that contains the database.

Also the .mdb file is not write protected.

I don´t know what can be the problem!

Please help me.

Thanks,

João Pinto
 
Now I've the following error:

Object_required

on line 61 that is

rstSimple.Fields("Source") = source
 
It's OK now! Here's the correct code:

Code:
<%
 Dim cnnSimple  ' ADO connection
 Dim rstSimple  ' ADO recordset
 Dim strDBPath  ' path to our Access database (*.mdb) file
 Dim MySQL 
 Dim endereco, datapub
 strDBPath = Server.MapPath("db/rssdb.mdb")
 Set cnnSimple = Server.CreateObject("ADODB.Connection")
 cnnSimple.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & ";"
 Set rstSimple = Server.CreateObject("ADODB.Recordset")
 MySQL = "SELECT * FROM news"
 endereco = "CBS News"
 rstSimple.Open MySQL, cnnSimple, 3, 3
 URLToRSS = "[URL unfurl="true"]http://www.cbsnews.com/feeds/rss/main.rss"[/URL]	
 MaxNumberOfItems = 50
 MainTemplateHeader = "<table>"
 MainTemplateFooter = "</table>"
 ItemTemplate = "<tr><td><a href=" & """{LINK}""" & ">{TITLE}</a><BR>{DESCRIPTION}</td></tr>"
 ErrorMessage = "No news available!"
 Set xmlHttp = Server.CreateObject("MSXML2.XMLHTTP.3.0")
 xmlHttp.Open "Get", URLToRSS, false
 xmlHttp.Send()
 RSSXML = xmlHttp.ResponseText
 Set xmlDOM = Server.CreateObject("MSXML2.DomDocument.3.0")
 xmlDOM.async = false
 xmlDOM.LoadXml(RSSXML)
 Set xmlHttp = Nothing
 Set RSSItems = xmlDOM.getElementsByTagName("item")
 Set xmlDOM = Nothing
 RSSItemsCount = RSSItems.Length-1
 if RSSItemsCount > 0 then 
 	Response.Write MainTemplateHeader
 End If
 j = -1
 For i = 0 To RSSItemsCount
 	Set RSSItem = RSSItems.Item(i)
  	for each child in RSSItem.childNodes
   		Select case lcase(child.nodeName)
     		case "title"
           		RSStitle = child.text
     		case "link"
           		RSSlink = child.text
	 		case "description"
           		RSSdescription = child.text
	 		case "pubDate"
           		datapub = child.text
   		End Select
		
  	next
		rstSimple.AddNew
		rstSimple.Fields("Source")  = endereco
		rstSimple.Fields("Headline")  = RSStitle
    	rstSimple.Fields("Description")  = RSSdescription
    	rstSimple.Fields("Link")  = RSSlink
		rstSimple.Fields("Date")  = RSSpubdate
		rstSimple.Update
		
  	j = J+1
  	if J<MaxNumberOfItems then

		%>
		<img src="/images/arrow.gif" width="14" height="9" align="middle"><a href="<%= RSSlink%>" target="_blank" class="hyperblue" onMouseOver="window.status='More...';return true;" onMouseOut="window.status='';return true;"><%= RSStitle%></a><br> <div align="justify"><a class="black"><%= RSSdescription%></a></div><br> <div align="justify"><a class="black"><%= datapub%></a></div>
    	<br class="smallblack"> <% ItemContent = ""
  	End if
 Next
 rstSimple.Close
 Set rstSimple = Nothing
 cnnSimple.Close
 Set cnnSimple = Nothing
 if RSSItemsCount > 0 then 
  Response.Write MainTemplateFooter
 else 
  Response.Write ErrorMessage
 End If %>

Thanks all for the tips.

João Pinto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top