XML parameter

vinnie881

Well-known member
Joined
Sep 3, 2006
Messages
152
Programming Experience
3-5
I have a System.XML.XMLDOCUMENT and I'm looking to pass the xml as a parameter to sql.

I created a dataaccess class, but I am getting invalid cast.

So here's some sample code

VB.NET:
dim x as new system.xml.document
x.load("C:\MyXML.xml")

dim adapt as new mydataAdaptors.OneoofMyStoredProcedureAdaptors
dim  t as new oneofMyStoreProcedureTables

'Here is where it is expecting the XML type in sql, but in vb it just says type OBJECT.
'I am thinking I need to somehow send the steam or something.  

adapt.fill(t,x)

I've tried
VB.NET:
adapt.fill(t,x)
'and
adapt.fill(t,x.outerXML)

Both give me a invalid cast.

I'd really appriciate any help I can get!

Thanks!
 
The issue was in the xml file.

For whatever reason sql could not accept a xml string that had a DOCTYPE in it.

Rather then passing the XML string in VB to a XML Column in sql, I had my stored procedure use a varchar type instead of XML.

Once I had the XML in a varchar from within my procedure I used.

declare @XML xml
set @XML = Convert(xml,@Myxml,2)

and that would then allow me to import. Without using the convert I didn't know how to do it. It works well now.
 
Back
Top