无法为“"字段创建子列表" [英] cannot create child list for field " "

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

问题描述

大家好,当我尝试将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);
            }
        }

推荐答案

好吧,看起来您创建了一个名为dsnew DataSet,然后在它仍然为空时将其写入XML. .尝试先填充DataSet,然后将其写入XML.
Well, it looks like you create a new DataSet named ds, then write it to XML when it''s still empty. Try filling the DataSet first, then write it to XML.


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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆