Friday, January 21, 2011

Parser Error Message: Ambiguous match found.

This error was being received after converting a project from .NET 1.1 to 3.5.
The issue is most likely due to two variable names in code behind differing only by case.

Here are two links for further research if needed:
Peter Johnson's blog (real name??)
Eran Sandler's post.

Monday, January 10, 2011

Assembly's manifest definition does not match the assembly reference

This error can occur if an attempt is made to reference a different version of a .dll and the previous .dll is being imported during compilation.

To fix this issue:
  • Bring up the properties of the project having the problem
  • Click on the "Reference Paths" tab
  • Verify that the reference path defined is the actual path of the .dll that should be referenced.

Friday, December 17, 2010

Update the result of an inner join from a SQL table

UPDATE @result
SET selectiondate=eventdatetime
FROM @result r
INNER JOIN (
  SELECT r.id, MAX(h.EventDateTime) eventdatetime
  FROM @result r
  LEFT JOIN statehistory h WITH (NOLOCK) ON h.id = r.id AND h.eventid = @CONST_SelectedEvent
  GROUP BY r.id
) d ON d.id=r.id

Tuesday, November 23, 2010

Page Lifecycle

Simple graphic showing an asp.net pages lifecycle

Thursday, October 28, 2010

Manage XML data in SQL column when column is not of type XML

Below is a way to manage XML in SQL when the column is not of type XML

First, cast the data into a temp table as XML
DECLARE @results TABLE (Id INT, Detail XML)
--Filter results
INSERT INTO @results
select t.Id, d.extrainfo
from tableOne t
inner join into i on i.Id=t.Id
where i.institutionid=6 and t.state < 270

Combine relevent data for easier manipulation
DECLARE @x XML;
SELECT @x = ( SELECT
  [Id],
  [Detail].query('
  for $a in /*:RootNode
  return ')
FROM @results AS results
FOR XML AUTO);


Simple select statement
SELECT Id = T.Item.value('../@Id', 'INT'),
  Date = T.Item.value('@date', 'DATETIME')
FROM @x.nodes('results/detail') as T(Item)

Wednesday, October 20, 2010

Save DataSet as XML and then Recreate the DataSet from saved XML

In this example, the DataSet is also prepended with a distinct node that can be used to include specific data the DataSet didn't include.

using(DataSet ds = GetSpecificData(dataID)){
  XmlDocument xd = new XmlDocument();
  //Here is where the unique node is created and added to the XmlDocument
  XmlNode node = xd.CreateNode(XmlNodeType.Element, "NewRootOfXML", null);
  xd.AppendChild(node);

  using(MemoryStream ms = new MemoryStream()) {
    ds.WriteXml(ms);

    //Reset the position to the start of the stream
    ms.Seek(0, SeekOrigin.Begin);

    StreamReader sr = new StreamReader(ms);
    node.InnerXml = sr.ReadToEnd();
  }

  xd.SaveTheXML();
}

  XmlDocument xDoc = TheSavedXML();
  XmlNode nd = xDoc .SelectSingleNode("/NewRootOfXML");

  DataSet data = new DataSet();
  XmlTextReader reader = new XmlTextReader(nd.InnerXml, XmlNodeType.Element, null);
  data.ReadXml(reader);

Friday, October 15, 2010

SQL paging or selecting a specific range of rows

With a large set of data within a table, it is time consuming to query the entire set. To quickly return a specific section, follow the example below.

SELECT *
FROM
  (SELECT row_number() over (order by first, last DESC) as row, i.first, i.last, i.ex
    FROM information i
    WHERE i.infotype = @type
  ) AS Results
WHERE row BETWEEN 19000 AND 19900