Server: Msg 8624, Level 16, State 13, Line 1
Internal SQL Server error.
if above error comes it means that you are missing
GROUP BY in inner query.
Search This Blog
Friday, July 10, 2009
Thursday, July 9, 2009
Update a table from another table
Below is the sql statement to update one table from another table.In the following case memodtl is getting update from podtl.
UPDATE memodtl
SET type=y.type, origin=y.origin, Grade=y.Grade, length=y.length, width=y.width, thickness= y.Thickness, MemoQty=y.Nos
FROM podtl y
WHERE memodtl.memono=y.pono and memodtl.memodt=y.podt and memodtl.revNo = y.RevNo and memodtl.RecNo=y.ReCno and memodtl.SeqNo = y.SeqNo
UPDATE memodtl
SET type=y.type, origin=y.origin, Grade=y.Grade, length=y.length, width=y.width, thickness= y.Thickness, MemoQty=y.Nos
FROM podtl y
WHERE memodtl.memono=y.pono and memodtl.memodt=y.podt and memodtl.revNo = y.RevNo and memodtl.RecNo=y.ReCno and memodtl.SeqNo = y.SeqNo
Friday, June 12, 2009
How to bind gridview from dataset using XSLT
-------------------------------
1:-XSLT file: Books.xsl
This is your XSLT file code
-------------------------------
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<books>
<xsl:apply-templates select="//book"/>
</books>
</xsl:template>
<xsl:template match="book">
<xsl:if test="price > 200">
<book>
<xsl:attribute name="name">
<xsl:value-of select="name"/>
</xsl:attribute>
<xsl:attribute name="specialization">
<xsl:value-of select="specialization"/>
</xsl:attribute>
<xsl:attribute name="author">
<xsl:value-of select="author"/>
</xsl:attribute>
<xsl:attribute name="publication">
<xsl:value-of select="publication"/>
</xsl:attribute>
<xsl:attribute name="price">
<xsl:value-of select="price"/>
</xsl:attribute>
</book>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
--------------------------
2:-GridView Control
------------------------
add a gridview control in your web page with xmlDataSource as follows:
<asp:GridView ID="gvXML" runat="server" DataSourceID="XmlDataSource1">
<HeaderStyle BackColor="Gray" />
</asp:GridView>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" TransformFile="~/BindGridView.xsl">
</asp:XmlDataSource>
Note:This control always look data in <book name="ask" price="1220"> </book>
format
----------------------------
3:-C# code
Add this code in your Code-Behind file
--------------------------
SqlConnection myCon = new SqlConnection(@"data source=192.168.2.200\sql2k;uid=sa;pwd=bench;database=DMS1");
SqlDataAdapter da = new SqlDataAdapter("select name, price, specialization, author, publication from book", myCon);
DataSet ds = new DataSet();
ds.DataSetName = "books";
da.Fill(ds, "book");
xmlDataSource2.Data = ds.GetXml();
After doing the above steps you will get the following output
1:-XSLT file: Books.xsl
This is your XSLT file code
-------------------------------
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<books>
<xsl:apply-templates select="//book"/>
</books>
</xsl:template>
<xsl:template match="book">
<xsl:if test="price > 200">
<book>
<xsl:attribute name="name">
<xsl:value-of select="name"/>
</xsl:attribute>
<xsl:attribute name="specialization">
<xsl:value-of select="specialization"/>
</xsl:attribute>
<xsl:attribute name="author">
<xsl:value-of select="author"/>
</xsl:attribute>
<xsl:attribute name="publication">
<xsl:value-of select="publication"/>
</xsl:attribute>
<xsl:attribute name="price">
<xsl:value-of select="price"/>
</xsl:attribute>
</book>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
--------------------------
2:-GridView Control
------------------------
add a gridview control in your web page with xmlDataSource as follows:
<asp:GridView ID="gvXML" runat="server" DataSourceID="XmlDataSource1">
<HeaderStyle BackColor="Gray" />
</asp:GridView>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" TransformFile="~/BindGridView.xsl">
</asp:XmlDataSource>
Note:This control always look data in <book name="ask" price="1220"> </book>
format
----------------------------
3:-C# code
Add this code in your Code-Behind file
--------------------------
SqlConnection myCon = new SqlConnection(@"data source=192.168.2.200\sql2k;uid=sa;pwd=bench;database=DMS1");
SqlDataAdapter da = new SqlDataAdapter("select name, price, specialization, author, publication from book", myCon);
DataSet ds = new DataSet();
ds.DataSetName = "books";
da.Fill(ds, "book");
xmlDataSource2.Data = ds.GetXml();
After doing the above steps you will get the following output
| name | specialization | author | publication | price |
|---|---|---|---|---|
| ASP.Net 3.5 | Web Programming Using C# and VB | Bill Thomas | Wrox | 560.00 |
| C# 3.5 | C# 2008 Powered by Microsoft | Microsoft Team | Wrox | 600.00 |
How to bind an xml datasource to a gridview
XMl Document: books.xml
This is your xml document
-------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<books>
<book>
<name> Ajax 2.0 </name>
<specialization> Programming Language </specialization>
<author>Wiley ,Bill</author>
<publication>Wrox</publication>
<price>200.00</price>
</book>
<book>
<name> ASP.Net 3.5</name>
<specialization>Web Programming Using C# and VB </specialization>
<author>Bill Thomas</author>
<publication>Wrox</publication>
<price>560.00</price>
</book>
<book>
<name>C# 3.5 </name>
<specialization> C# 2008 Powered by Microsoft </specialization>
<author> Microsoft Team </author>
<publication>Wrox</publication>
<price>600.00</price>
</book>
</books>
-------------------------------
XSLT file: Books.xsl
This is your XSLT file code
-------------------------------
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<books>
<xsl:apply-templates select="//book"/>
</books>
</xsl:template>
<xsl:template match="book">
<xsl:if test="price > 200">
<book>
<xsl:attribute name="name">
<xsl:value-of select="name"/>
</xsl:attribute>
<xsl:attribute name="specialization">
<xsl:value-of select="specialization"/>
</xsl:attribute>
<xsl:attribute name="author">
<xsl:value-of select="author"/>
</xsl:attribute>
<xsl:attribute name="publication">
<xsl:value-of select="publication"/>
</xsl:attribute>
<xsl:attribute name="price">
<xsl:value-of select="price"/>
</xsl:attribute>
</book>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
--------------------------
GridView Control
------------------------
add a gridview control in your web page with xmlDataSource as follows:
<asp:GridView ID="gvXML" runat="server" DataSourceID="XmlDataSource1">
<HeaderStyle BackColor="Gray" />
</asp:GridView>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/books.xml" TransformFile="~/BindGridView.xsl">
</asp:XmlDataSource>
Note:This control always look data in <book name="ask" price="1220"> </book>
format
After doing the above steps you will get the following output:
This is your xml document
-------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<books>
<book>
<name> Ajax 2.0 </name>
<specialization> Programming Language </specialization>
<author>Wiley ,Bill</author>
<publication>Wrox</publication>
<price>200.00</price>
</book>
<book>
<name> ASP.Net 3.5</name>
<specialization>Web Programming Using C# and VB </specialization>
<author>Bill Thomas</author>
<publication>Wrox</publication>
<price>560.00</price>
</book>
<book>
<name>C# 3.5 </name>
<specialization> C# 2008 Powered by Microsoft </specialization>
<author> Microsoft Team </author>
<publication>Wrox</publication>
<price>600.00</price>
</book>
</books>
-------------------------------
XSLT file: Books.xsl
This is your XSLT file code
-------------------------------
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/">
<books>
<xsl:apply-templates select="//book"/>
</books>
</xsl:template>
<xsl:template match="book">
<xsl:if test="price > 200">
<book>
<xsl:attribute name="name">
<xsl:value-of select="name"/>
</xsl:attribute>
<xsl:attribute name="specialization">
<xsl:value-of select="specialization"/>
</xsl:attribute>
<xsl:attribute name="author">
<xsl:value-of select="author"/>
</xsl:attribute>
<xsl:attribute name="publication">
<xsl:value-of select="publication"/>
</xsl:attribute>
<xsl:attribute name="price">
<xsl:value-of select="price"/>
</xsl:attribute>
</book>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
--------------------------
GridView Control
------------------------
add a gridview control in your web page with xmlDataSource as follows:
<asp:GridView ID="gvXML" runat="server" DataSourceID="XmlDataSource1">
<HeaderStyle BackColor="Gray" />
</asp:GridView>
<asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/books.xml" TransformFile="~/BindGridView.xsl">
</asp:XmlDataSource>
Note:This control always look data in <book name="ask" price="1220"> </book>
format
After doing the above steps you will get the following output:
| name | specialization | author | publication | price |
|---|---|---|---|---|
| ASP.Net 3.5 | Web Programming Using C# and VB | Bill Thomas | Wrox | 560.00 |
| C# 3.5 | C# 2008 Powered by Microsoft | Microsoft Team | Wrox | 600.00 |
How to tranform xml Document into html table using XSLT and C#
XMl Document: books.xml
-------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<books>
<book>
<name> Ajax 2.0 </name>
<specialization> Programming Language </specialization>
<author>Wiley ,Bill</author>
<publication>Wrox</publication>
<price>200.00</price>
</book>
<book>
<name> ASP.Net 3.5</name>
<specialization>Web Programming Using C# and VB </specialization>
<author>Bill Thomas</author>
<publication>Wrox</publication>
<price>560.00</price>
</book>
<book>
<name>C# 3.5 </name>
<specialization> C# 2008 Powered by Microsoft </specialization>
<author> Microsoft Team </author>
<publication>Wrox</publication>
<price>600.00</price>
</book>
</books>
-------------------------------
XSLT file: books.xsl
------------------------------
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<xsl:element name="books">
<table >
<tr bgcolor="gray">
<td>Name</td>
<td>Specialization</td>
<td>Author</td>
<td>Publication</td>
<td>Price</td>
</tr>
<xsl:apply-templates select="//book" ></xsl:apply-templates>
</table>
</xsl:element>
</xsl:template>
<xsl:template match="book">
<tr>
<xsl:if test="price > 400">
<td width="100">
<xsl:value-of select="name"/>
</td>
<td width="100">
</td>
<td width="100">
<xsl:value-of select="author"/>
</td>
<td width="100">
<xsl:value-of select="publication"/>
</td>
<td width="100">
</td>
</xsl:if>
</tr>
</xsl:template>
</xsl:stylesheet>
-----------------------------
Method 1
Step1:
add a literal control to the page like below:
<asp:Literal ID="ltr1" runat="server"></asp:Literal>
Step2:
C#
using System.IO;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Xsl;
public partial class xmlTesting : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
XPathDocument xPathDoc = new XPathDocument(Server.MapPath("books.xml"));
XslTransform xTrans = new XslTransform();
xTrans.Load(Server.MapPath("Books.xsl"));
StringWriter Sw = new StringWriter();
xTrans.Transform(xPathDoc, null, Sw);
ltr1.Text = Sw.ToString();
}
}
Method 2
add a xml control to the page:
<asp:Xml ID="xml1" runat="server" DocumentSource="~/books.xml" TransformSource="~/Books.xsl"></asp:Xml>
-------------------------------------------------------------------
Output
-------------------------------------------------------------------
-------------------------------
<?xml version="1.0" encoding="utf-8" ?>
<books>
<book>
<name> Ajax 2.0 </name>
<specialization> Programming Language </specialization>
<author>Wiley ,Bill</author>
<publication>Wrox</publication>
<price>200.00</price>
</book>
<book>
<name> ASP.Net 3.5</name>
<specialization>Web Programming Using C# and VB </specialization>
<author>Bill Thomas</author>
<publication>Wrox</publication>
<price>560.00</price>
</book>
<book>
<name>C# 3.5 </name>
<specialization> C# 2008 Powered by Microsoft </specialization>
<author> Microsoft Team </author>
<publication>Wrox</publication>
<price>600.00</price>
</book>
</books>
-------------------------------
XSLT file: books.xsl
------------------------------
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<xsl:element name="books">
<table >
<tr bgcolor="gray">
<td>Name</td>
<td>Specialization</td>
<td>Author</td>
<td>Publication</td>
<td>Price</td>
</tr>
<xsl:apply-templates select="//book" ></xsl:apply-templates>
</table>
</xsl:element>
</xsl:template>
<xsl:template match="book">
<tr>
<xsl:if test="price > 400">
<td width="100">
<xsl:value-of select="name"/>
</td>
<td width="100">
</td>
<td width="100">
<xsl:value-of select="author"/>
</td>
<td width="100">
<xsl:value-of select="publication"/>
</td>
<td width="100">
</td>
</xsl:if>
</tr>
</xsl:template>
</xsl:stylesheet>
-----------------------------
Step1:
add a literal control to the page like below:
<asp:Literal ID="ltr1" runat="server"></asp:Literal>
Step2:
C#
using System.IO;
using System.Xml;
using System.Xml.XPath;
using System.Xml.Xsl;
public partial class xmlTesting : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
XPathDocument xPathDoc = new XPathDocument(Server.MapPath("books.xml"));
XslTransform xTrans = new XslTransform();
xTrans.Load(Server.MapPath("Books.xsl"));
StringWriter Sw = new StringWriter();
xTrans.Transform(xPathDoc, null, Sw);
ltr1.Text = Sw.ToString();
}
}
add a xml control to the page:
<asp:Xml ID="xml1" runat="server" DocumentSource="~/books.xml" TransformSource="~/Books.xsl"></asp:Xml>
-------------------------------------------------------------------
-------------------------------------------------------------------
| name | specialization | author | publication | price |
|---|---|---|---|---|
| ASP.Net 3.5 | Web Programming Using C# and VB | Bill Thomas | Wrox | 560.00 |
| C# 3.5 | C# 2008 Powered by Microsoft | Microsoft Team | Wrox | 600.00 |
Monday, June 8, 2009
How to handle: 'sys' is undefined.
Add this code in web.config if above error come:
<system.web>
<httphandlers>
<add verb="GET" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler" validate="false">
</add>
</httphandlers>
</system.web>
<system.web>
<httphandlers>
<add verb="GET" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler" validate="false">
</add>
</httphandlers>
</system.web>
Saturday, June 6, 2009
Subscribe to:
Posts (Atom)