v.urgent:how to refer the column name in dataadapter

hi
how can i refer the table column.
like i have this query select a,b from table.
i use it as
 Using da As New OracleDataAdapter(FCommand)
                     Try
                            FConnection.Open()
                            da.Fill(dt)
i want to use the table column a specifically ... how can i do that?
thanks
LVL 1
samir25Asked:
Who is Participating?
 
renjurdevanConnect With a Mentor Commented:

xmlDoc = dt.Rows(i)("xml_data") ' getting sting xml

objXmlDoc.LoadXml(xmlDoc) ' Load that string into XmlDocument object infact in memory

Dim XmlNode objNode = objXmlDoc.selectSingleNode("//Error")

string data = objNode.InnerText               '  will return the data


Regards
Renju
0
 
renjurdevanCommented:
dt.Columns("a") or dt.Columns(0)

dt.Columns("b") or dt.Columns(1)

Regards
Renju
0
 
renjurdevanCommented:
dt.Rows(RowNumber)(column index or name)

like

dt.Rows(0)("a")  Or dt.Rows(0)(0)

dt.Rows(0)("b")  Or dt.Rows(0)(1)

Regards
Renju


0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
samir25Author Commented:
can i use the above before  da.Fill(dt) or after?
0
 
samir25Author Commented:
it doesnt solve my purpose :-(

FConnection.Open()
                            Dim xmlDoc As New XmlDocument
                            Dim OracleClob As OracleClob
                            da.Fill(dt)
                            xmlDoc = dt.Columns(7)
                            xmlDoc.LoadXml(xmlDoc)
i get this error
Value of type 'System.Data.DataColumn' cannot be converted to 'System.Xml.XmlDocument'.
0
 
renjurdevanCommented:
yes !! if you want to loop thru rows

you can use like

For i = 0 To dt.Rows.Count - 1

a = dt(i)("a")
b = dt(i)("b")

Next

if you are operating with string appending use StringBuilder!! otherwise it may hit perfomance

Regards
Renju
0
 
renjurdevanCommented:
above "a" and "b" are strings !!

Get the value in strings and try load it into XmlDocument
like

string xmlDoc = dt(i)("a")

XmlDocument objXmlDoc = New XmlDocument ()

objXmlDoc.LoadXml(xmlDoc)              ' FYI::: where xmlDoc is string data

Regards
Renju

0
 
samir25Author Commented:
sorry i am not too clear. i am referring 8 columns in my query and hence it should be dt.columns(7). why shoudl i refer to rows. can you pls help write exactly what steps to follow
0
 
renjurdevanCommented:
You should mention the row which you are fetching data!!

dt.columns(7) will return a datacolumn collection!! not the data from column 7!!

to get a data you shld use like

string strData = dt(0)(7)   Here you will get 7Th column data from 0th Row

You may have more than 1 rows present in your table so you shld specify the row number,  which you want to fetch data

Regards
Renju
0
 
renjurdevanCommented:
FConnection.Open()
                            Dim szData as STring
                            Dim xmlDoc As New XmlDocument
                            Dim OracleClob As OracleClob
                            da.Fill(dt)
                            szData = dt.(0)(7)            ' Assuming that you hav only one row and first row contains data
                            xmlDoc.LoadXml(szData)


Regards
Renju
0
 
samir25Author Commented:
ok here is what i did
Using FCommand As New OracleCommand(query, FConnection)
                    Dim da As New OracleDataAdapter(FCommand)
                    Try
                        FConnection.Open()
                        Dim xmlDoc As String
                        da.Fill(dt)
                        Dim objXmlDoc As New XmlDocument
                        For i = 0 To dt.Rows.Count - 1
                            xmlDoc = dt(i)("xml_data")
                            objXmlDoc.LoadXml(xmlDoc)
                        Next
                        FConnection.Close()
                        FCommand.Dispose()
                        FConnection.Dispose()
and i get below error on dt(i)("xml_data")

Class 'System.Data.DataTable' cannot be indexed because it has no default property.      
0
 
renjurdevanCommented:
i extreamly sorry i missed the key word "row"

xmlDoc = dt.Rows(i)("xml_data")

FYI:: here each and every iteration xml is being loaded into objXmlDoc!!


Regards
Renju
0
 
samir25Author Commented:
yes error is not there.
can you help me some more of your expert inputs.
in asp i had xf.LoadXML(xdoc.selectSingleNode("//Error").xml)...and i would refer the node of the xml.her how can i do in asp.net
xf.LoadXML(xdoc.selectSingleNode("//Error").xml)
objXmlDoc.loadXML(????.SelectSingleNode("//Error").xml)

and then i need to refer this particular column to the gridview. how can i do that?
0
 
samir25Author Commented:
where xdoc would be
 Set xdoc = CreateObject("MSXML2.DOMDocument.4.0")  
    xdoc.async=false
0
 
renjurdevanCommented:
your last question is not clear to me!!

Regards
Renju
0
 
renjurdevanCommented:
well the flow is like

xmlDoc = dt.Rows(i)("xml_data") ' getting sting xml

objXmlDoc.LoadXml(xmlDoc) ' Load that string into XmlDocument object infact in memory

Dim XmlNode objNode = objXmlDoc.selectSingleNode("//Error")


Regards
Renju



0
 
samir25Author Commented:
i want to extract a node from the xml(which is an error node) and put it the string in the gridview column. i already bind the grid as GridView1.DataBind() and i refer each datafield in the aspx page.

but now i want to do 2 things
1. extract the node content from the xml file and
2. show is gridview
0
 
samir25Author Commented:
well how do you know all this. if you searched on this then pls tell me how do you seacrch for this kind of help. its frustating to not know all this small stuff. once u know it seems small..and once u dont its big.

how do i refer it in the grid column.
0
 
samir25Author Commented:
i am getting this error on using the above
ORA-06502: PL/SQL: numeric or value error
 Dim xData As String
 For i = 0 To dt.Rows.Count - 1
                            xmlDoc = dt.Rows(i)("xml_data")
                            objXmlDoc.LoadXml(xmlDoc)
                            objNode = objXmlDoc.SelectSingleNode("//Error")
                            xData = objNode.InnerText
                        Next
0
 
renjurdevanCommented:
;)  Get a book on Asp.Net  .. seems like a fresher in this domain!!


To bind these values in grid column do it in RowBinding even  of grid view !! use template column


http://www.codeproject.com/useritems/create_template_columns.asp
http://msdn2.microsoft.com/en-us/library/ms228046.aspx

Regards
Renju
0
 
samir25Author Commented:
i removed the innertext change adn still i am getting error. here is the error i get
ORA-06503: PL/SQL: Function returned without value
ORA-06512: at "PackageName.ProcName", line 39

this error was not comign bef but nowits coming.
basically i am referrign to a view where xml_data is this
PackageName.ProcName.blob2clob(compressor.blob_decompress(xml_data)) as XML_DATA
0
 
samir25Author Commented:
the error that was coming went away ... as suddenly it came equally surprising it disappeared. is it an vs.net limitation or what?
0
 
samir25Author Commented:
no i am not a fresher. its just job scope which keeps changing. i was working on asp.net 2 yrs back. and then started workign on diff tech. now my work again involves asp.net. all this small small things i already struggled b4 but unfortunatley i forget easily. maybe concepts not clear. but i didnt work on xml before
0
 
samir25Author Commented:
this is coming out to be extremely slow. bec ia m referring to all the xml files which are huge. i never had this issue with asp. they were fast. is there anything i can do to make it fast
0
 
renjurdevanCommented:
as far your code is concern you are reading xml documents for each iteration

how many Rows you have in data table?
depends upon the rows time may increase!!
i dont know what you are trying to achive with this code or i hardly understood ur situation!!

Regards
Renju
0
 
samir25Author Commented:
ok ... i am basically providing the user the id and couple of other things from table in which error has occured. the xml file contains the content why the error occured. so apart from table data i need to show one node from xml file (for each record there is one xml file)..in my case error files are around 300
0
 
samir25Author Commented:
here is another way to refer xml ..
http://www.oracle.com/technology/pub/articles/price_dotnet2.html

woudl this process make it faster?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.