Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

storing HTML code in Access Db via TinyMCE editor

Posted on 2007-08-02
4
Medium Priority
?
539 Views
Last Modified: 2012-08-13
storing HTML code in Access Db via TinyMCE editor
0
Comment
Question by:grafixgirl
  • 2
4 Comments
 
LVL 6

Expert Comment

by:mcorrente
ID: 19618188
...
0
 

Author Comment

by:grafixgirl
ID: 19618207
I am using TinyMCE  as an html page editor in ASP.net,  I got the editor running and everything seems to be working, only thing is how do I save the page now in access db
0
 
LVL 13

Accepted Solution

by:
John Mc Hale earned 1500 total points
ID: 19622076
Depending on the size (in bytes) of your HTML page, it can either be stored in a Memo or OLE Object (BLOB) type field. I'm not entirely sure what you are trying to do, but you can use Microsoft ActiveX Data Objects Library (version 2.6+) to read the HTML page into an ADODB.Stream, and then serialize the stream to the database field.

' Saving the HTML Page
Dim strFileName As String
strFileName = ' replace with the physical path to your HTML page
Dim conn As ADODB.Connection
Dim rs As New ADODB.Recordset
Dim st As New ADODB.Stream
st.Type = adTypeBinary
st.Open
' Load HTML Page from disk file
st.LoadFromFile strFileName
' Set database connection
set conn = CurrentProject().Connection
' Open a recordset containing the field you want to save your HTML in
rs.Open "SELECT SomeField FROM SomeTable WHERE(SomeCondition)", conn, adOpenDynamic, adLockOptimistic
' Store stream data into database field
rs!SomeField = st.Read
' Update
rs.Update
' Tidy up
rs.Close
st.Close
set st = Nothing
set rs = Nothing
set conn = Nothing


' Retrieving the HTML Page
Dim strFileName As String
strFileName = ' the physical path to where you want to store the file
Dim conn As ADODB.Connection
Dim rs As New ADODB.Recordset
Dim st As New ADODB.Stream
st.Type = adTypeBinary
st.Open
' Set database connection
set conn = CurrentProject().Connection
' Open a recordset containing the field you have your HTML saved in using appropriate criteria
rs.Open "SELECT SomeField FROM SomeTable WHERE(SomeCondition)", conn, , adLockReadOnly
' Retrieve the HTML data into stream
st.Write rs!SomeField
' Save stream to physical file
st.SaveToFile strFileName
' Tidy up
rs.Close
st.Close
set st = Nothing
set rs = Nothing
set conn = Nothing

Hope this provides you with some ideas!
0
 

Author Comment

by:grafixgirl
ID: 19623116
Thank you for your response,
I am now able to edit the page, and post the updated page to view, but still having problem updating/storing it to the Access db. The following code displays my changed/edited content
---------------
void Page_Load(object sender, EventArgs e)
{
    Response.Write(Request.Form["content"]);
}
------------------
The foloowing code I am using to update, but u can tell it doesn't work
------------------------
<asp:AccessDataSource ID="ctrlDataSource" runat="server" DataFile="~/access_db/db.mdb"
            UpdateCommand="UPDATE [pages] SET content=@content WHERE [page]='Default.aspx'">      
</asp:AccessDataSource
------
how do I store the content to db?
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question