Wrox Programmer Forums
|
BOOK: Beginning ASP.NET Databases Also see the forum ASP Databases for more general discussions of ASP database issues not directly related to these books.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 18th, 2004, 11:14 AM
Authorized User
 
Join Date: Apr 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mahir
Default Ch05 DisplayColumnInfo.aspx

Hi,

I am reading the book and doing the the try it out as described everything is looking fine and suddenly my program responded abruptly. I downloaded the code and it is working fine but my code which I wrote which samne as the code I downloaded not working I am sending all the files. Below

Comments.xml file

<?xml version="1.0" encoding="utf-8" ?>
<Reviews>
    <Review>
        <ReviewID>1</ReviewID>
        <ProductName>Chai</ProductName>
        <EmployeeID>6</EmployeeID>
        <Date>2001-01-01</Date>
        <Comment>"Even tastier my mother's"</Comment>
    </Review>
    <Review>
        <ReviewID>2</ReviewID>
        <ProductName>Chang</ProductName>
        <EmployeeID>7</EmployeeID>
        <Date>2002-02-02</Date>
        <Comment>""Reminds me of my childhood school lunch"</Comment>
    </Review>
    <Review>
        <ReviewID>3</ReviewID>
        <ProductName>Aniseed Syrup</ProductName>
        <EmployeeID>8</EmployeeID>
        <Date>2003-03-03</Date>
        <Comment>"Gave me the courage to enlist in the Navy"</Comment>
    </Review>
    <Review>
        <ReviewID>4</ReviewID>
        <ProductName>Chai</ProductName>
        <EmployeeID>8</EmployeeID>
        <Date>2003-03-03</Date>
        <Comment>"Of questionable taste"</Comment>
    </Review>
</Reviews>

Comments.xsd File

<?xml version="1.0" standalone="yes" ?>
<schema xmlns="http://ww3.w3.org/2001/XMLSchema">
  <element name="Reviews">
    <complexType>
      <choice maxOccurs="unbounded">
        <element name="Review">
          <complexType>
            <sequence>
              <element name="ReviewID" type="int" />
              <element name="ProductName" type="string" />
              <element name="EmployeeID" type="int" />
              <element name="Date" type="date" />
              <element name="Comment" type="string" />
            </sequence>
          </complexType>
        </element>
      </choice>
    </complexType>
  </element>
</schema>

main file DisplayColumnInfo.aspx

<%@ Page Language="VB" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.SqlClient" %>
<script runat="server">

    Sub Page_Load(Source As Object, E As EventArgs)

        'Connection
        Dim strConnection As String = ConfigurationSettings.AppSettings("NWind")
        Dim objConnection As New SqlConnection(strConnection)

        'Sql Statement Setup
        Dim strSqlProducts As String = "Select ProductID, ProductName From Products "
        strSqlProducts &= "WHERE ProductID < 5 ORDER BY ProductID;"

        'Create DataSet and DataAdapter with properties that apply to all tables
        Dim objDataSet As New DataSet("ProductPage")
        Dim objAdapter As New SqlDataAdapter(strSqlProducts, objConnection)

        'First Table - "Comments Table" From XML
        objDataSet.ReadXmlSchema(Server.MapPath("Comments. xsd"))
        objDataSet.ReadXml(Server.MapPath("Comments.xml"))

        'Second Table - "Products Table" From Northwind
        objAdapter.Fill(objDataSet, "dtProducts")

        'Dignostic Print of tables in objDataset - loop through DataSet.Tables
        Dim strNames As String
        Dim c As DataColumn
        Dim iTableItem As DataTable

        For Each iTableItem In objDataSet.Tables

            strNames &= "Table Name: " & iTableItem.tableName & "<br/>"

            For Each c In iTableItem.Columns

                strNames &= "- Column " & c.ColumnName & " is of type " _
                            & c.DataType.ToString & "<br/>"

            Next

        Next

        Response.Write(strNames)

    End Sub

</script>
<html>
<head>
    <title>Display Column Information</title>
</head>
<body>
    <form runat="server">

    </form>
</body>
</html>

Please help
Thanks
Mahir Ali Ahmed


Mahir Ali Ahmed
__________________
Mahir Ali Ahmed
 
Old May 19th, 2004, 12:00 AM
Authorized User
 
Join Date: Apr 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mahir
Default

Hi,
Once Again, I think nobody is interested in finding the solution. Please Help.

Any Body
Take Care
Mahir

Mahir Ali Ahmed
 
Old May 19th, 2004, 01:48 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

What do you mean with "Once Again, I think nobody is interested in finding the solution"??

I think you have to be a little patient on this forum; you can't expect an answer within a couple of hours after your post. People from all over the world come here to contribute, so when you are awake and make a post, others may be sound asleep. Sometimes you get a quick answer, sometimes it takes a while, and sometimes you don't get an answer at all.

That said, can you describe your problem in more detail? What do you mean with "my program responded abruptly"? Do you get an error? If so, what's the error?

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old May 19th, 2004, 06:00 AM
Authorized User
 
Join Date: Apr 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mahir
Default

Hi,

Sorry about my attitude I am little nervous and tensed the program should read the schema file and has the table review from the xml file but it is outputting the table name as schema. why is that.

Thanks
Take Care
Mahir

Mahir Ali Ahmed
 
Old May 19th, 2004, 06:37 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Yeah, don't worry about that.

The table is called schema as that is apparently the default name assigned by the Read methods when you don't specify an explicit name. You can rename the table if you want:

objDataSet.Tables(0).TableName = "Products"

I think the data in the .xsd file cannot be converted to correct DataTable data or conflicts with the stuff in the XML file. When I tried to bind the data in the "schema" table to a Grid, it failed.

It looks like the ReadXml and ReadXmlSchema methods are conflicting. If you comment out the first call (to ReadXmlSchema) everything will work as expected. That's because ReadXml generates a schema as well.....

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Schizophrenia by Sonic Youth (Track 1 from the album: Sister)
 
Old May 19th, 2004, 10:24 AM
Authorized User
 
Join Date: Apr 2004
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to mahir
Default

Thank you

Brother I also want to know how u put this
"While typing this post, I was listening to: Schizophrenia by Sonic Youth (Track 1 from the album: Sister)"
In your message is it dynamic or you manually typed it

Thanks
Take Care
Mahir

Mahir Ali Ahmed
 
Old May 19th, 2004, 10:36 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Ah, it's good that you ask. I used to have a "What's This?" after the info, but since a recent disk reformat, that has gone. It's back now, so follow the What's This? link at the end of my post to find out.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Watersnood by Hans Teeuwen (Track 2 from the album: Trui Cd 2) What's This?
 
Old April 2nd, 2005, 04:38 PM
Registered User
 
Join Date: Mar 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am facing some problem in converting the xml file to a dataset.
the xml format is like
<newdataset>
<table>
       <attr1></attr1>
</table>
</newdataset>

it was returned by the 'getxml' method of the dataset.

now i want to convert it again to dataset. but i could not find any method to do this. how it can be done?

i am new to .net. please help me as early as possible.

Rushikesh Darshane






Similar Threads
Thread Thread Starter Forum Replies Last Post
Ch05: TIO-0503-HyperlinkTarget.aspx dogrady BOOK: Beginning ASP.NET 2.0 and Databases 1 April 17th, 2008 03:52 AM
ch05 - example3 idroulia BOOK: Beginning JavaServer Pages 1 March 15th, 2008 09:42 AM
ch05 no validation error humayunlalzad BOOK: Beginning XML 3rd Edition 2 November 15th, 2006 06:55 AM
Ch05 IE not properly display XML david_4092 BOOK: Beginning ASP.NET 1.0 1 October 24th, 2003 01:23 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.