Connecting Tech Pros Worldwide Help | Site Map

removing dbo. from xml results

 
LinkBack Thread Tools Search this Thread
  #1  
Old November 12th, 2005, 01:09 AM
Gary Brewer
Guest
 
Posts: n/a
Default removing dbo. from xml results

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



  #2  
Old November 12th, 2005, 01:09 AM
Keith Chadwick
Guest
 
Posts: n/a
Default 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]


  #3  
Old November 12th, 2005, 01:09 AM
Gary Brewer
Guest
 
Posts: n/a
Default 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]


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,662 network members.