本文介绍了无法为“"字段创建子列表"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,当我尝试将SQL数据库表的内容保存到XML文件时,抛出此错误,无论我哪里出错了,如果您能提供帮助,将不胜感激.感谢Louise :) x



Hi guys Its throwing this error when i try to save the contents of my SQL database table to an XML file, any idea where i am going wrong, it would be much appreciated if you could help. thanks Louise :) x



private void databasexml_Click(object sender, EventArgs e)
        {
            string sql = "SELECT * FROM BookDetails";
            DataSet ds = new DataSet();
            BindingSource bs = new BindingSource();
            SqlDataAdapter sda = new SqlDataAdapter(sql, stringConnection);

            try
            {
          
            ds.WriteXml("C:\\Users\\Louise Tooze\\Desktop\\XMLFile2");
            dataGridView1.DataMember = "BookDetails";
            sda.Fill(ds);
            
            dataGridView1.DataSource = ds;
            dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            dataGridView1.Update();
            sda.Update(ds);

            sda.Dispose();

            MessageBox.Show("XML File created Successfully");
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

推荐答案


这篇关于无法为“"字段创建子列表"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-22 13:04