读书人

vs2008 C# Winform中水晶表入片

发布时间: 2012-02-07 17:45:36 作者: rapoo

vs2008 C# Winform中水晶表入片的
我使用的是vs2008建的Crystal report
首先我先建立rpt案
接著建立.xsd案,利用ADO.NET的方式.xsd做rpt的料格式
xsd示如下:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="XMLSchema1"
targetNamespace="http://tempuri.org/XMLSchema1.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/XMLSchema1.xsd"
xmlns:mstns="http://tempuri.org/XMLSchema1.xsd"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
>
<xs:element name="Document">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="packinglist">
<xs:complexType>
<xs:sequence>
<xs:element name="P2" type="xs:string" minOccurs="0" />
<xs:element name="P3" type="xs:base64Binary" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>

接著在.cs中入片
部分程式如下:

ds.Tables.Add();
ds.Tables[0].Columns.Add("P3", System.Type.GetType("System.Byte[]"));
ds.Tables[0].Columns.Add("P2", System.Type.GetType("System.String"));
ds.Tables[0].AcceptChanges();
ds.AcceptChanges();
FileStream fLogo = new FileStream(g_sPath + @"\barcode.png", FileMode.Open, FileAccess.Read);
BinaryReader bReader = new BinaryReader(fLogo);
byte[] bt = bReader.ReadBytes(Convert.ToInt32(bReader.BaseStream.Length));
if (ds.Tables[0].Rows.Count <= 0)
{
DataRow dr = ds.Tables[0].NewRow();
ds.Tables[0].Rows.Add(dr);
ds.Tables[0].AcceptChanges();
ds.AcceptChanges();
}
ds.Tables[0].Rows[0]["P3"] = bt;
ds.Tables[0].Rows[0]["P2"] = "ABC";
ds.AcceptChanges();
fLogo.Close();

doc.SetDataSource(ds.Tables[0]);
crystalReportViewer1.ReportSource = doc;

最後料型base64Binary的"P3"拉近rpt中,
示出的片只有框,中是空白的,
另外我oracle中取BLOB料型的料,rpt,所示出的片也是空白的,但字串、字等皆可正常示
想各位高手是否有好的解方案。


[解决办法]

探讨
後我又使用DataSet1.xsd,P3的DataTypeSystem.Byte[]
再rpt去用DataSet1.xsd料源,所跑出的片是空白的,外有黑框
可是P2(String)是可以正常示的。
不知道是我CR安,是程式方面哪有,您解答

读书人网 >.NET

热点推荐