Hello Kevin ,
First you understood my need very well :-)
2nd 10x for your answer
BUT , i would like to take my question forward ,
i don't want to use dataset .
i have stored procedure that return XML and not recordset .
i m getting the xml from the sp into some XmlReader
and i m building the XML string by looping on the XmlReader .
this is the code ,
Dim cmd As New SqlCommand()
Dim xmlr As XmlReader
Dim sMyXml As String
REM -- CREATE A COMMAND TEXT AND OPEN THE CONNECTION
cmd.Connection = m_Conn ' connection
cmd.CommandType = CommandType.Text
cmd.CommandText = sSqlStatement ' some stored procedure that return an
XML .
xmlr = cmd.ExecuteXmlReader
xmlr.Read()
Do While xmlr.ReadState <> xmlr.ReadState.EndOfFile
sMyXml = sMyXml & xmlr.ReadOuterXml().ToString
Loop
xmlr.Close()
But the problem is that in some of my SP's I m getting the following error
Invalid attempt to GetBytes on column ''. The GetBytes function can only be
used on columns of type Text, NText, or Image.
And in other SP's every thing ok !
So my questions are
1) is it the best way to build an XML string with out using DataSet ?
2) why I m getting this invalid Error on some of my SP's and what
doe's it mean ?
10x
"Kevin Yu [MSFT]" <v-****@online.microsoft.com> wrote in message
news:oL*************@cpmsftngxa10.phx.gbl...
Hi Tiraman,
First of all, I would like to confirm my understanding of your issue. From
your description, I understand that you need to get the Xml results from a
SQL stored procedure. If there is any misunderstanding, please feel free
to let me know.
I think we can get the Xml data from the database and fill them to a
DataSet. Then, we join all the strings in the table to form a complete xml
document. We can use an XmlTextReader to read it. Here is a code snippet
for your reference.
this.sqlConnection1.Open();
SqlDataAdapter sda = new SqlDataAdapter("GetEmployeeXml",
this.sqlConnection1);
sda.SelectCommand.CommandType = CommandType.StoredProcedure;
DataSet ds = new DataSet();
sda.Fill(ds);
string s = string.Empty;
for(int i=0; i<ds.Tables[0].Rows.Count; i++)
{
s += ds.Tables[0].Rows[i][0].ToString();
}
this.sqlConnection1.Close();
this.textBox1.Text = s;
XmlTextReader r = new XmlTextReader(new System.IO.StringReader(s));
r.Read();
HTH. If anything is unclear, please feel free to reply to the post.
Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."