This might belong in the XML forum, but I am trying here first.
I have a variable named Authors. Sometimes I will insert one author into the database, sometimes more than one author will be inserted into the database.
The page that performs the update is a .cs page. Here is the layout:
I think I need to include something like:
This definitely works for updating one author's name:
I just can not nail down how to insert a string of author's names.
I have a variable named Authors. Sometimes I will insert one author into the database, sometimes more than one author will be inserted into the database.
The page that performs the update is a .cs page. Here is the layout:
Code:
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Linq;
using System.Text;
using System.Xml;
namespace Library.Requests
{
public class LibraryDoc : RequestItem
{
private _Author;
public Author { get { return _end; } }
public DateTime StartDate { get { return _start; } }
public LibraryDoc()
: base()
{
}
public LibraryDoc(Int32 RequestID)
: base(ItemID)
{
XmlElement root = _doc.DocumentElement;
XmlNode node;
node = root.SelectSingleNode("Author");
if (node != null) this._author = node.InnerText;
public LibraryDoc(Int32 RequestID, String Title, Int32 RequestedBy, String Author)
: base(RequestID, Title, CreatedBy, 10, Description)
{
this._Author = author
XmlDocument xml = new XmlDocument();
XmlNode root = xml.CreateElement("fields");
xml.AppendChild(root);
node = xml.CreateElement("Author");
node.AppendChild(xml.CreateTextNode(this.Author));
root.AppendChild(node);
//now write everything to SQL
this.WriteXml(xml);
}
public static LibraryDoc GetAuthorDocByID(Int32 RequestID)
{
return new LibraryDoc(RequestID);
}
public static void UpdateLibraryDoc(Int32 LibraryDocID, String Author)
{
LibraryDoc old = LibraryDoc.GetLibraryDocByID(LibraryDocID);
if (old.Author != Author) RequestItem.UpdateField(LibraryDocID, Editor, "Author", Author);
}
}
}
Code:
if old.Autor != Author
{
string Authorseparatedvalue = string.Empty;
if (Author.Length != 0)
{
//What goes here to insert the string?? Perhaps something like this - Authorseparatedvalue = string.Join(",", (string[])Location.ToArray(typeof(string))); }
Code:
if (old.Author != Author) RequestItem.UpdateField(LibraryDocID, Editor, "Author", Author);
Comment