Connecting Tech Pros Worldwide Forums | Help | Site Map

removing dbo. from xml results

Gary Brewer
Guest
 
Posts: n/a
#1: Nov 12 '05
Hi,

I am using SQXML3.0 SP2 with some code like this -

using(SqlConnection sqlCon=new
SqlConnection(G2P2DataObject.GetLocalDBConnectionS tring())) {

sqlCon.Open();

SqlXmlCommand sqlCom=new SqlXmlCommand("MYCONNSTRING");

sqlCom.RootTag="myevents";

sqlCom.CommandType=SqlXmlCommandType.Sql;

sqlCom.CommandText="EXECUTE MonthView";

XmlReader xmlReader=sqlCom.ExecuteXmlReader();



xmlDoc.Load(xmlReader);

xmlReader.Close();


sqlCon.Close();

}





My resulting xmlDoc contains



- <myevents>
- <dbo.Event EventID="B61C37EA-20E0-4EDE-8A58-0029D86918AD"
StartDate="2003-11-02T00:00:00">
- <dbo.Organisation OrganisationID="1E916A45-37C6-46AD-B58A-DCDC6ED74D89"
ShortName="DEFAULT" CountryID="3E33816B-14CA-4B52-8A43-A65A715692AE"
SectorID="00000000-0000-0000-0000-000000000000">
<EventTypeEvent EventTypeID="34921299-7586-427D-B438-7256FEA4202F" />
</dbo.Organisation>
</dbo.Event>


I was wondering how I would go about dropping the dbo. from the element
tags, I am using FOR XML AUTO, ELEMENTS



Keith Chadwick
Guest
 
Posts: n/a
#2: Nov 12 '05

re: removing dbo. from xml results


The reason you are getting that is because in your select statement you are
using the user name on the from clause as in

select something from dbo.mytable

since your security context should be set in your connection string you do
not need the dbo, instead just use the table name

cheers
keith chadwick


"Gary Brewer" <gary@nospam.com> wrote in message
news:OkYTCpAuDHA.1740@TK2MSFTNGP12.phx.gbl...[color=blue]
> Hi,
>
> I am using SQXML3.0 SP2 with some code like this -
>
> using(SqlConnection sqlCon=new
> SqlConnection(G2P2DataObject.GetLocalDBConnectionS tring())) {
>
> sqlCon.Open();
>
> SqlXmlCommand sqlCom=new SqlXmlCommand("MYCONNSTRING");
>
> sqlCom.RootTag="myevents";
>
> sqlCom.CommandType=SqlXmlCommandType.Sql;
>
> sqlCom.CommandText="EXECUTE MonthView";
>
> XmlReader xmlReader=sqlCom.ExecuteXmlReader();
>
>
>
> xmlDoc.Load(xmlReader);
>
> xmlReader.Close();
>
>
> sqlCon.Close();
>
> }
>
>
>
>
>
> My resulting xmlDoc contains
>
>
>
> - <myevents>
> - <dbo.Event EventID="B61C37EA-20E0-4EDE-8A58-0029D86918AD"
> StartDate="2003-11-02T00:00:00">
> - <dbo.Organisation OrganisationID="1E916A45-37C6-46AD-B58A-DCDC6ED74D89"
> ShortName="DEFAULT" CountryID="3E33816B-14CA-4B52-8A43-A65A715692AE"
> SectorID="00000000-0000-0000-0000-000000000000">
> <EventTypeEvent EventTypeID="34921299-7586-427D-B438-7256FEA4202F" />
> </dbo.Organisation>
> </dbo.Event>
>
>
> I was wondering how I would go about dropping the dbo. from the element
> tags, I am using FOR XML AUTO, ELEMENTS
>
>[/color]


Gary Brewer
Guest
 
Posts: n/a
#3: Nov 12 '05

re: removing dbo. from xml results


Thanks, I should have looked harder :)


"Keith Chadwick" <kchadwick@leewardsystems.com> wrote in message
news:u6H7erBuDHA.4056@TK2MSFTNGP11.phx.gbl...[color=blue]
> The reason you are getting that is because in your select statement you[/color]
are[color=blue]
> using the user name on the from clause as in
>
> select something from dbo.mytable
>
> since your security context should be set in your connection string you do
> not need the dbo, instead just use the table name
>
> cheers
> keith chadwick
>
>
> "Gary Brewer" <gary@nospam.com> wrote in message
> news:OkYTCpAuDHA.1740@TK2MSFTNGP12.phx.gbl...[color=green]
> > Hi,
> >
> > I am using SQXML3.0 SP2 with some code like this -
> >
> > using(SqlConnection sqlCon=new
> > SqlConnection(G2P2DataObject.GetLocalDBConnectionS tring())) {
> >
> > sqlCon.Open();
> >
> > SqlXmlCommand sqlCom=new SqlXmlCommand("MYCONNSTRING");
> >
> > sqlCom.RootTag="myevents";
> >
> > sqlCom.CommandType=SqlXmlCommandType.Sql;
> >
> > sqlCom.CommandText="EXECUTE MonthView";
> >
> > XmlReader xmlReader=sqlCom.ExecuteXmlReader();
> >
> >
> >
> > xmlDoc.Load(xmlReader);
> >
> > xmlReader.Close();
> >
> >
> > sqlCon.Close();
> >
> > }
> >
> >
> >
> >
> >
> > My resulting xmlDoc contains
> >
> >
> >
> > - <myevents>
> > - <dbo.Event EventID="B61C37EA-20E0-4EDE-8A58-0029D86918AD"
> > StartDate="2003-11-02T00:00:00">
> > - <dbo.Organisation[/color][/color]
OrganisationID="1E916A45-37C6-46AD-B58A-DCDC6ED74D89"[color=blue][color=green]
> > ShortName="DEFAULT" CountryID="3E33816B-14CA-4B52-8A43-A65A715692AE"
> > SectorID="00000000-0000-0000-0000-000000000000">
> > <EventTypeEvent EventTypeID="34921299-7586-427D-B438-7256FEA4202F" />
> > </dbo.Organisation>
> > </dbo.Event>
> >
> >
> > I was wondering how I would go about dropping the dbo. from the element
> > tags, I am using FOR XML AUTO, ELEMENTS
> >
> >[/color]
>
>[/color]


Closed Thread


Similar .NET Framework bytes