The Data Provider will use TdParameter.Offset and TdParameter.Size properties when the TdParameter.Value property is set to one of the following objects:
The TdParameter.Offset and TdParameter.Size properties will be ignored if TdParameter.Value is set to a System.Xml.XmlReader.
The following example shows how Xml contained in a TextReader and XmlReader is sent to Teradata:
C# |
Copy Code |
---|---|
public void InsertXml(TdCommand cmd) { // The first parameter will be a TextReader. // StreamReader inherits from TextReader. StreamReader xmlStream = new StreamReader(@"c:\XmlFile1.xml"); // The second parameter will be a XmlReader. // XmlTextReader inherits from XmlReader. XmlTextReader xmlData = new XmlTextReader(@"c:\XmlFile2.xml"); cmd.Parameters.Clear(); cmd.CommandText = "insert into XmlTable (XmlColumn1, XmlColumn2) values (?, ?)"; cmd.Parameters.Add(null, TdType.TdXml); cmd.Parameters[0].Value = xmlStream; // if the Offset and Size properties are used, it is the responsibility of the // application to make sure that the resulting Xml that is sent to the Advanced SQL Engine // is valid. An exception will be thrown if the Xml is invalid. cmd.Parameters[0].Size = 100; cmd.parameters[0].Offset = 50; cmd.Parameters.Add(null, TdType.TdXml); cmd.Parameters[1].Value = xmlData // The Size and Offset properties are ignored when a XmlReader is used. // Sending data to Teradata TdDataReader reader = cmd.ExecuteNonQuery(); } |