Monday, March 12, 2012

How to Handle Oracles XMLElement output in VS.NET 2005

Hi,

Oracle 9i, VS.NET 2005

I have a query that uses Oracle's XMLElement function. It returns XML. What I don't know, is how I use VS.NET to handle the outupt. I just want to take this output and write it to a file. Has anyone done this before? How is this accomplished?

I'm trying something like this but I've no idea if this is correct or not:

// connect to oracle

OracleConnection oConn =newOracleConnection("Data Source=databasename;Persist Security Info=True;User ID=userid;Password=pwd");OracleCommand oCommand = oConn.CreateCommand();

oCommand.CommandText =

"SELECT XMLElement( a huge multiline, multi join statement.....";

oCommand.CommandType =

CommandType.Text;

oConn.Open();

// retrieve the output.OracleDataReader oread = oCommand.ExecuteReader();

while (oread.Read())

{

Response.Write(oread.GetString(0) + "<br />" );

}

oread.Close();

oConn.Close();

The query runs in SQLPlus.

However, I'm slightly mystified as to what to use to handle the output from Oracle's XMLElement. Should I use an OracleDataReader?

Thanks in advance,

Paul

Hi,

I think you can return as a string to the c# code in the form XML string.Then use XMLDOM object loadXML(XML string) method so that you get dom object with xml data then if wanted to load it into dataset use DOM object's DOM.dataset() method.

It may help you out

Labels: , , , , , , , , , , ,

How to handle DBNull DataType for Ms access ??

Hi,

I have problem in using this function to check if the field is empty or null :

Let say , I have connect to a Database and set up Dataset :

Dim Ds as dataset

Dim StrAddr as string

If IsDBNull( DS.tables("tblName").rows(0).item("Address")) then

LbMsg.text =" No address entered."

else

StrAddr = DS.tables("tblName").rows(0).item("Address"))

end if

I have error msg : Can not cast DBNull to string.

All I wanted is to check the field address to see if it is empty or no data entered.

Please help.

How to check ? How to handle if the field has nothing in it at all. How to use IsDBNull() ?

Thanks in advance.

Try this:

StrAddr = DS.tables("tblName").rows(0).item("Address").ToString

If StrAddr ="" then StrAddr = "No Address Entered"

Tim

Labels: , , , , , , , , , , , , ,