writing scheme out to xsd file

jvcoach23

Well-known member
Joined
May 22, 2003
Messages
192
Location
Saybrook, IL
Im trying to write out the scheme to an xsd file so that I can use it in crystal cr. eventually im trying to have images show up.. based on the Crystal Reports .Net programming book page 372 and 3. I dont know much about xsd files.. but it doesnt look right.. was wondering if someone could take a look. here it the file

Ex:
Code:
<?xml version="1.0" standalone="yes"?>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
  <xs:element name="NewDataSet" msdata:IsDataSet="true">
    <xs:complexType>
      <xs:choice maxOccurs="unbounded">
        <xs:element name="Pic">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="vcFileName" type="xs:string" minOccurs="0" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
        <xs:element name="Image_x0020_Table">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="Image" type="xs:unsignedByte" minOccurs="0" />
              <xs:element name="vcFileName" type="xs:string" minOccurs="0" />
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:choice>
    </xs:complexType>
  </xs:element>
</xs:schema>

the vcFileName looks to be in there twice.. was on the unbounded.
Here is what Im doing
Code:
  Dim cn As SqlConnection
        Dim cm As New SqlCommand
        Dim da As New SqlDataAdapter
        Dim ds As New DataSet
        Dim dr As DataRow
        Dim dt As DataTable
        dt = New DataTable("Image Table")
        Dim dc As DataColumn

        dc = New DataColumn("Image", GetType(System.Byte))
        dt.Columns.Add(dc)

        dc = New DataColumn("vcFileName", GetType(System.String))
        dt.Columns.Add(dc)



        cn = New SqlConnection("pwd=pw; UID=id; server=(local); database=Shannon")
        cm = New SqlCommand("select vcFileName from tblShannon", cn)
        cm.CommandType = CommandType.Text

        Try
            cn.Open()
            da.SelectCommand = cm
            cn.Close()
        Catch ex As Exception
            Throw ex
        End Try

        da.Fill(ds, "Pic")


        For Each dr In ds.Tables("Pic").Rows
            Debug.WriteLine(dr.Item("vcFileName"))
            dr = dt.NewRow
            dr("vcFileName") = dr("vcFileName")
            dt.Rows.Add(dr)
        Next

        ds.Tables.Add(dt)

        only do this first time run report
        ds.WriteXmlSchema("ImageTable.xsd")
I need to read the vcFileName from a database.. so I need to do that, but is that was is screwing up the xsd file.

hope someone is willing to explain
thanks
shannon
 
ok.. i think i understand that the pic element is coming from the dataset where Im filling it from the dataadapter. so how do i fill a dataset from the data adapter, and then also add a column to that element so that I dont create two elements like I have done in the above example.

thanks
shannon
 
Playing around some more...

I understand now that when I do a da.fill(ds, "Pics"), i create a "table in my dataset. For this the table has 1 column named vcFileName. When I issue a
Code:
dt.Columns.Add("Image", GetType(System.Byte))
dt.Columns.Add("vcFileName", GetType(System.String))
ds.tables.add(dt)
now there is a second table created in the ds. So when I script out the ds with WriteXmlScheme, I have two element names. Problem is, the data from the database is in the Pic element.. and the second column I added called Images had no relationship to the first. so I cant link the two. I need to link the two so that I can try to figure out how to load an image into the image column so I can bring it back for the crystal report

Thanks
shannon
 
Back
Top