473,320 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

URGENT Error: CS0117: 'System.Data.DataTable' does not contain a definition for 'WriteXml'

Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: CS0117: 'System.Data.DataTable' does not contain a
definition for 'WriteXml'

Source Error:

Line 55: da.Fill(Datos, "Datos");
Line 56: Session["Tabla"]=ListaTabla.SelectedItem.Text;
Line 57:
Datos.Tables["Datos"].WriteXml(Server.MapPath(Session["Tabla"] + ".xml"));
Line 58: DataGrid1.DataSource=Datos;
Line 59: DataGrid1.DataBind();
Source File: c:\inetpub\wwwroot\PDM\excel\Default.aspx Line: 57

The code:
<%@ Page Language="c#" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Xml" %>
<%@ import Namespace="System.Xml.Xsl" %>
<%@ import Namespace="System.Data.SqlClient" %>
<HTML>
<HEAD>
<script runat="server">

//definimos como publica la conexion a la base de datos
public SqlConnection conDB = new SqlConnection();

public void Page_Load(Object sender, EventArgs E) {
//la primera vez que carga la pagina obtenemos la lista de Bases de
datos
if (Page.IsPostBack == false) {
conDB.ConnectionString = "data
source=10.195.17.7;database=devnew;uid=cuprykma;pw d=ehs123";
/*con "sp_databases" obtenemos la lista de bases de datos en una
instancia de SQL Server
para MySQL se usa "show databases" */
SqlDataAdapter da = new SqlDataAdapter("sp_databases", conDB);
DataSet ds = new DataSet();
da.Fill(ds, "DBases");
ListaDB.DataSource=ds;
//filtramos los datos y solo asociamos la columna "DATABASE_NAME" al
dropdownlist
ListaDB.DataTextField="DATABASE_NAME";
ListaDB.DataBind();
}
}

void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) {
//como ya el usuario selecciono una base de datos activamos el boton
de consultas
Consultar.Enabled=true;
conDB.ConnectionString = "data source=10.195.17.7;initial catalog="
+ ListaDB.SelectedItem.Text + ";integrated security=SSPI;persist security
info=False;uid=cuprykma;pwd=ehs123;packet size=4096";
/*con la cosulta "select * from SYSOBJECTS where TYPE = 'U' and name
<> 'dtproperties' order by NAME"
obtenemos todas las tablas de usuario que hay en una base de datos.
en MySQL usamos "show tables" y en Oracle Usamos "select * from
tab;"*/
SqlDataAdapter da = new SqlDataAdapter("select * from SYSOBJECTS
where TYPE = 'U' and name <> 'dtproperties' order by NAME", conDB);
DataSet ds = new DataSet();
da.Fill(ds, "Tablas");
ListaTabla.DataSource=ds;
//filtramos de nuevo, ahora solo nos intersa la columna "name" con
los nombres de la tablas
ListaTabla.DataTextField="name";
ListaTabla.DataBind();
//aparecemos el boton para hacer la conversion a excel
Convertir.Visible=false;
//y desaparecemos el de consulta
Consultar.Visible=true;
}

public DataSet Datos = new DataSet();

public void Consultar_Click(object sender, EventArgs e) {
conDB.ConnectionString = "data source=10.195.17.7;initial catalog="
+ ListaDB.SelectedItem.Text + ";integrated security=SSPI;persist security
info=False;uid=cuprykma;pwd=ehs123;packet size=4096";
//traemos los datos de la tabla usando la BD selecionada en
ListaTabla y la tabla seleccionada
SqlDataAdapter da = new SqlDataAdapter("select * from " +
ListaTabla.SelectedItem.Text, conDB);
da.Fill(Datos, "Datos");
Session["Tabla"]=ListaTabla.SelectedItem.Text;
Datos.Tables["Datos"].WriteXml(Server.MapPath(Session["Tabla"] +
".xml"));
DataGrid1.DataSource=Datos;
DataGrid1.DataBind();
Consultar.Visible=false;
Convertir.Visible=true;
}

void Button1_Click(object sender, EventArgs e) {
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath(Session["Tabla"] + ".xml"));
XmlDataDocument xdd = new XmlDataDocument(ds);
XslTransform xt = new XslTransform();
xt.Load(Server.MapPath("Excel.xsl"));
xt.Transform(xdd, null, Response.OutputStream);
Response.End();
}

</script>
</HEAD>
<body>
<form runat="server" ID="Form1">
<asp:HyperLink id="HyperLink1" runat="server"
NavigateUrl="Back">Properties</asp:HyperLink>
<table cellspacing="3" cellpadding="7" align="center">
<tbody>
<tr>
<td>
Database</td>
<td>
Table</td>
</tr>
<tr>
<td>
<asp:DropDownList id="ListaDB"
runat="server" OnSelectedIndexChanged="DropDownList1_SelectedInde xChanged"

AutoPostBack="True"></asp:DropDownList>
</td>
<td>
<asp:DropDownList id="ListaTabla"
runat="server">
<asp:ListItem
Value="(Tablas)">(Tables)</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td colspan="2">
<div align="center">
<asp:Button id="Consultar"
onclick="Consultar_Click" runat="server" Text="Consultar"
Enabled="False"></asp:Button>
<asp:Button id="Convertir"
onclick="Button1_Click" runat="server" Text="Convert To Excel"
Visible="False"></asp:Button>
</div>
</td>
</tr>
</tbody>
</table>
<p>
</p>
<p align="center">
<asp:DataGrid id="DataGrid1" runat="server"
BorderStyle="None" BorderWidth="1px" BorderColor="#CC9966"
BackColor="White" CellPadding="4">
<FooterStyle forecolor="#330099"
backcolor="#FFFFCC"></FooterStyle>
<HeaderStyle font-bold="True" forecolor="#FFFFCC"
backcolor="#990000"></HeaderStyle>
<PagerStyle horizontalalign="Center"
forecolor="#330099" backcolor="#FFFFCC"></PagerStyle>
<SelectedItemStyle font-bold="True"
forecolor="#663399" backcolor="#FFCC66"></SelectedItemStyle>
<ItemStyle forecolor="#330099"
backcolor="White"></ItemStyle>
</asp:DataGrid>
</p>
</form>
</body>
</HTML>

--
LUIS ESTEBAN VALENCIA
MICROSOFT DCE 3.
MIEMBRO ACTIVO DE ALIANZADEV
http://spaces.msn.com/members/extremed/
Nov 19 '05 #1
1 6762
Vko
This method is only defined for DataSet not for DataTable.

Replace :
Datos.Tables["Datos"].WriteXml(Server.MapPath(Session["Tabla"] + ".xml"));
by
Datos.WriteXml(Server.MapPath(Session["Tabla"] + ".xml"));
"Luis Esteban Valencia" wrote:
Compilation Error
Description: An error occurred during the compilation of a resource required
to service this request. Please review the following specific error details
and modify your source code appropriately.

Compiler Error Message: CS0117: 'System.Data.DataTable' does not contain a
definition for 'WriteXml'

Source Error:

Line 55: da.Fill(Datos, "Datos");
Line 56: Session["Tabla"]=ListaTabla.SelectedItem.Text;
Line 57:
Datos.Tables["Datos"].WriteXml(Server.MapPath(Session["Tabla"] + ".xml"));
Line 58: DataGrid1.DataSource=Datos;
Line 59: DataGrid1.DataBind();
Source File: c:\inetpub\wwwroot\PDM\excel\Default.aspx Line: 57

The code:
<%@ Page Language="c#" Debug="true" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Xml" %>
<%@ import Namespace="System.Xml.Xsl" %>
<%@ import Namespace="System.Data.SqlClient" %>
<HTML>
<HEAD>
<script runat="server">

//definimos como publica la conexion a la base de datos
public SqlConnection conDB = new SqlConnection();

public void Page_Load(Object sender, EventArgs E) {
//la primera vez que carga la pagina obtenemos la lista de Bases de
datos
if (Page.IsPostBack == false) {
conDB.ConnectionString = "data
source=10.195.17.7;database=devnew;uid=cuprykma;pw d=ehs123";
/*con "sp_databases" obtenemos la lista de bases de datos en una
instancia de SQL Server
para MySQL se usa "show databases" */
SqlDataAdapter da = new SqlDataAdapter("sp_databases", conDB);
DataSet ds = new DataSet();
da.Fill(ds, "DBases");
ListaDB.DataSource=ds;
//filtramos los datos y solo asociamos la columna "DATABASE_NAME" al
dropdownlist
ListaDB.DataTextField="DATABASE_NAME";
ListaDB.DataBind();
}
}

void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) {
//como ya el usuario selecciono una base de datos activamos el boton
de consultas
Consultar.Enabled=true;
conDB.ConnectionString = "data source=10.195.17.7;initial catalog="
+ ListaDB.SelectedItem.Text + ";integrated security=SSPI;persist security
info=False;uid=cuprykma;pwd=ehs123;packet size=4096";
/*con la cosulta "select * from SYSOBJECTS where TYPE = 'U' and name
<> 'dtproperties' order by NAME"
obtenemos todas las tablas de usuario que hay en una base de datos.
en MySQL usamos "show tables" y en Oracle Usamos "select * from
tab;"*/
SqlDataAdapter da = new SqlDataAdapter("select * from SYSOBJECTS
where TYPE = 'U' and name <> 'dtproperties' order by NAME", conDB);
DataSet ds = new DataSet();
da.Fill(ds, "Tablas");
ListaTabla.DataSource=ds;
//filtramos de nuevo, ahora solo nos intersa la columna "name" con
los nombres de la tablas
ListaTabla.DataTextField="name";
ListaTabla.DataBind();
//aparecemos el boton para hacer la conversion a excel
Convertir.Visible=false;
//y desaparecemos el de consulta
Consultar.Visible=true;
}

public DataSet Datos = new DataSet();

public void Consultar_Click(object sender, EventArgs e) {
conDB.ConnectionString = "data source=10.195.17.7;initial catalog="
+ ListaDB.SelectedItem.Text + ";integrated security=SSPI;persist security
info=False;uid=cuprykma;pwd=ehs123;packet size=4096";
//traemos los datos de la tabla usando la BD selecionada en
ListaTabla y la tabla seleccionada
SqlDataAdapter da = new SqlDataAdapter("select * from " +
ListaTabla.SelectedItem.Text, conDB);
da.Fill(Datos, "Datos");
Session["Tabla"]=ListaTabla.SelectedItem.Text;
Datos.Tables["Datos"].WriteXml(Server.MapPath(Session["Tabla"] +
".xml"));
DataGrid1.DataSource=Datos;
DataGrid1.DataBind();
Consultar.Visible=false;
Convertir.Visible=true;
}

void Button1_Click(object sender, EventArgs e) {
Response.ContentType = "application/vnd.ms-excel";
Response.Charset = "";
DataSet ds = new DataSet();
ds.ReadXml(Server.MapPath(Session["Tabla"] + ".xml"));
XmlDataDocument xdd = new XmlDataDocument(ds);
XslTransform xt = new XslTransform();
xt.Load(Server.MapPath("Excel.xsl"));
xt.Transform(xdd, null, Response.OutputStream);
Response.End();
}

</script>
</HEAD>
<body>
<form runat="server" ID="Form1">
<asp:HyperLink id="HyperLink1" runat="server"
NavigateUrl="Back">Properties</asp:HyperLink>
<table cellspacing="3" cellpadding="7" align="center">
<tbody>
<tr>
<td>
Database</td>
<td>
Table</td>
</tr>
<tr>
<td>
<asp:DropDownList id="ListaDB"
runat="server" OnSelectedIndexChanged="DropDownList1_SelectedInde xChanged"

AutoPostBack="True"></asp:DropDownList>
</td>
<td>
<asp:DropDownList id="ListaTabla"
runat="server">
<asp:ListItem
Value="(Tablas)">(Tables)</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td colspan="2">
<div align="center">
<asp:Button id="Consultar"
onclick="Consultar_Click" runat="server" Text="Consultar"
Enabled="False"></asp:Button>
<asp:Button id="Convertir"
onclick="Button1_Click" runat="server" Text="Convert To Excel"
Visible="False"></asp:Button>
</div>
</td>
</tr>
</tbody>
</table>
<p>
</p>
<p align="center">
<asp:DataGrid id="DataGrid1" runat="server"
BorderStyle="None" BorderWidth="1px" BorderColor="#CC9966"
BackColor="White" CellPadding="4">
<FooterStyle forecolor="#330099"
backcolor="#FFFFCC"></FooterStyle>
<HeaderStyle font-bold="True" forecolor="#FFFFCC"
backcolor="#990000"></HeaderStyle>
<PagerStyle horizontalalign="Center"
forecolor="#330099" backcolor="#FFFFCC"></PagerStyle>
<SelectedItemStyle font-bold="True"
forecolor="#663399" backcolor="#FFCC66"></SelectedItemStyle>
<ItemStyle forecolor="#330099"
backcolor="White"></ItemStyle>
</asp:DataGrid>
</p>
</form>
</body>
</HTML>

--
LUIS ESTEBAN VALENCIA
MICROSOFT DCE 3.
MIEMBRO ACTIVO DE ALIANZADEV
http://spaces.msn.com/members/extremed/

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: RichW | last post by:
I've seen a couple other posts on this but no real answers. I'm trying to do a bulk insert and everything is fine until I run the objCom.ExecuteNonQuery() statement at which point I get the XML...
2
by: Patrick Huffer | last post by:
When I open a certain page, I receive a "Compilation Error" as follows: Compiler Error Message: CS0117: 'System.Web.UI.HtmlControls.HtmlForm' does not contain a definition for 'ValidateInput'...
3
by: Justin Dutoit | last post by:
Hey. I have the error CS0117 'BusinessLayer' does not contain a definition for 'MySoapHeader'. Below is a link to the asmx source, and the code which calls the web service. MS seems to do the same...
17
by: A_PK | last post by:
I have problem databinding the DataGrid with DataView/DataSet after the filter... I create the following proceudre in order for user to filter as many as they want, but the following code is only...
13
by: dbuchanan | last post by:
Hello, Here is the error message; ---------------------------- Exception Message: ForeignKeyConstraint Lkp_tbl040Cmpt_lkp302SensorType requires the child key values (5) to exist in the...
9
by: PeterWellington | last post by:
I have a column in a data table that stores enum values and assigns a default value: Dim dc As New DataColumn("TestEnumField", GetType(DayOfWeek)) dc.DefaultValue = DayOfWeek.Thursday When I...
4
by: B. | last post by:
Hi I have two projects, one written in MC++, and the other in C#. In MC++ header file, I have: namespace Domain { namespace Subdomain { namespace ManagedCPP { public class AClass
4
by: Neo Geshel | last post by:
Just moved to C# from VB.NET, frustrated to hell and back by inability to get much-copied (from about 20+ different resources) literal example to work. Master Page content: <meta...
5
by: preeti13 | last post by:
Hi friends i am getting the error in my application i don't know what to do please help me.i am useing a data bimder into my text box here is the my code <%@ Page language="c#"...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.