Answered by:
Reading Access DB Memo Field

Question
-
User-623365515 posted
Hey guys
just a short question: Why does the browser display me a div-tag around my memo fields that I read from an MS Access Database. Every other field type that i read is displayed perfectly...
thx in advance
greetings
Benedikt
Thursday, February 2, 2012 10:28 AM
Answers
-
User1477435862 posted
<tr> @thatReader.Read() { <td>bearbeitet von: @thatReader["Vorname"] @thatReader["Nachname"]</td> } <td><a href="\Dokumente\@thisReader["Anlagen"]">@thisReader["Anlagen"]</a></td> </tr>
should be
<tr> @{ thatReader.Read(); } <td>bearbeitet von: @thatReader["Vorname"] @thatReader["Nachname"]</td> <td><a href="\Dokumente\@thisReader["Anlagen"]">@thisReader["Anlagen"]</a></td> </tr>
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, February 2, 2012 11:03 AM
All replies
-
User1477435862 posted
Does the value of the Memo field contain the <div>? If not, you'll need to provide some code as the ASP.NET Forums crystal ball isn't working today. ;)
Thursday, February 2, 2012 10:31 AM -
User-623365515 posted
@{ // Create connection object for Microsoft Access OLE DB Provider. // Again, notice the @ sign prefacing the string literal so that the slashes // in the path name aren't interpreted as escape characters. var thisConnection = new OleDbConnection(@"Provider = Microsoft.ACE.OLEDB.12.0; Data Source = C:\Users\lechner\Documents\My Web Sites\Starter Site\App_Data\Aufgaben.accdb"); var IDr = ""; // Open Connection object thisConnection.Open(); IDr = Request.QueryString["ID"]; // Create SQL command object on this connection var thisCommand = thisConnection.CreateCommand(); var thatCommand = thisConnection.CreateCommand(); // Initialize SQL Select command to retrieve desired data thisCommand.CommandText = "SELECT * FROM Aufgaben WHERE ID =" + IDr; thatCommand.CommandText = "SELECT * FROM Aufgaben a, Kontakte b WHERE a.[Zugewiesen an] = b.ID"; // Create a DataReader object based on previously defined command object OleDbDataReader thisReader = thisCommand.ExecuteReader(); OleDbDataReader thatReader = thatCommand.ExecuteReader(); <table border="1"> @* Read() Advances the OleDbDataReader to the next record *@ @while(thisReader.Read()) { <tr> <td width="80%">@thisReader["Titel"]<br/><br/></td> <td width="20%">@thisReader["Enddatum"]</td> </tr> <tr> <td colspan="2" width="100%"> @thisReader["Beschreibung"] <br/> <br/> </td> </tr> <tr> @thatReader.Read() { <td>bearbeitet von: @thatReader["Vorname"] @thatReader["Nachname"]</td> } <td><a href="\Dokumente\@thisReader["Anlagen"]">@thisReader["Anlagen"]</a></td> </tr> } </table> }
here is some code ;) the tag @thisReader["Beschreibung"] is the memo field and here is what comes out :
Thursday, February 2, 2012 10:42 AM -
User-623365515 posted
and there is of course no div tag in the memo field, just a simple text, as you can see on the picture!
Thursday, February 2, 2012 10:43 AM -
User1477435862 posted
and there is of course no div tag in the memo field, just a simple text, as you can see on the picture!Look at the second row, it displays <div>...</div>, which means that it is in the value of the field.
Thursday, February 2, 2012 10:48 AM -
User1477435862 posted
If you look at the underlying HTML source (in the browser) you'll see <div> and </div> - the reason for this is that it has been HTML encoded because it's part of the Memo field's value. You can get around that by doing:
@Html.Raw(thisReader["Beschreibung"])
Thursday, February 2, 2012 10:52 AM -
User-623365515 posted
ah got it, edited from RichText to OnlyText.. ^^
But why does he prints out that true { } ? what am I doing wrong there?
Thursday, February 2, 2012 10:56 AM -
User1477435862 posted
<tr> @thatReader.Read() { <td>bearbeitet von: @thatReader["Vorname"] @thatReader["Nachname"]</td> } <td><a href="\Dokumente\@thisReader["Anlagen"]">@thisReader["Anlagen"]</a></td> </tr>
should be
<tr> @{ thatReader.Read(); } <td>bearbeitet von: @thatReader["Vorname"] @thatReader["Nachname"]</td> <td><a href="\Dokumente\@thisReader["Anlagen"]">@thisReader["Anlagen"]</a></td> </tr>
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Thursday, February 2, 2012 11:03 AM -
User-623365515 posted
thxxxx! :)
Friday, February 3, 2012 1:46 AM