protected void Button1_Click(object sender, EventArgs e)
{
string connString = WebConfigurationManager.ConnectionStrings["jdfxml"].ConnectionString;
using (SqlConnection conn = new SqlConnection(connString))
{
//SqlCommand command = conn.CreateCommand();
//command.CommandText = "SELECT PatientRecord FROM MedicalRecords WHERE PatientID = " + ID.ToString();
SqlDataAdapter adapter = new SqlDataAdapter("chaxun",conn );
adapter.SelectCommand.CommandType = CommandType.StoredProcedure;//指明Sql命令的操作类型是使用存储过程
DataSet ds = new DataSet();
adapter.Fill(ds, "bookType");
//Get the XML value as string
if (ds.Tables["bookType"].Rows.Count > 0)
{
string xml = ds.Tables["bookType"].ToString();
XmlDocument doc = new XmlDocument();
xml = xml.Trim();
doc.LoadXml(xml);
Literal1.Text = Server.HtmlEncode("Output : " + doc.OuterXml);
//Literal1.Text = xml; }
else
{
Response.Write("<script>alert('没有数据!')</script>");
}
}
}
运行后出现错误 :根级别上的数据无效。 行 1,位置 1。
怎么回事啊,大家帮帮忙啊,谢谢了。
{
string connString = WebConfigurationManager.ConnectionStrings["jdfxml"].ConnectionString;
using (SqlConnection conn = new SqlConnection(connString))
{
//SqlCommand command = conn.CreateCommand();
//command.CommandText = "SELECT PatientRecord FROM MedicalRecords WHERE PatientID = " + ID.ToString();
SqlDataAdapter adapter = new SqlDataAdapter("chaxun",conn );
adapter.SelectCommand.CommandType = CommandType.StoredProcedure;//指明Sql命令的操作类型是使用存储过程
DataSet ds = new DataSet();
adapter.Fill(ds, "bookType");
//Get the XML value as string
if (ds.Tables["bookType"].Rows.Count > 0)
{
string xml = ds.Tables["bookType"].ToString();
XmlDocument doc = new XmlDocument();
xml = xml.Trim();
doc.LoadXml(xml);
Literal1.Text = Server.HtmlEncode("Output : " + doc.OuterXml);
//Literal1.Text = xml; }
else
{
Response.Write("<script>alert('没有数据!')</script>");
}
}
}
运行后出现错误 :根级别上的数据无效。 行 1,位置 1。
怎么回事啊,大家帮帮忙啊,谢谢了。
但是还不行啊,上面的就是用的这个方法