我在项目中添加一个组件,然后导入一个数据库,运行出现下面的警告警告 1 “F:\study\net\MyProject\TestComponent\TestComponent\bookshopDataSet.Designer.cs”中的类型“TestComponent.bookshopDataSet”与“f:\study\net\MyProject\TestComponent\TestComponent\bin\Debug\TestComponent.dll”中的导入类型“TestComponent.bookshopDataSet”冲突。将使用“F:\study\net\MyProject\TestComponent\TestComponent\bookshopDataSet.Designer.cs”中的类型。 F:\study\net\MyProject\TestComponent\TestComponent\bookshopDataSet.Designer.cs 3630 33 TestComponent问题处在哪里了呢

解决方案 »

  1.   

    sigh...
    丢个code出来啦, 这样看死人呢
      

  2.   

    不好意思,刚看到各位大侠的回复.
    这是组件的代码:using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Data;
    using System.Data.SqlClient;namespace TestComponent
    {
        public class BookShop
        {
            public int GetRecordCount(string connString, string tableName)
            {
                int number = -1;
                SqlConnection conn = new SqlConnection(connString);
                SqlCommand command = new SqlCommand("select count(*)from" + tableName, conn);
                try
                {
                    conn.Open();
                    number = (int)command.ExecuteScalar();
                    conn.Close();
                }
                catch(Exception err)
                {
                    throw new Exception(err.Message);
                }
                return number;
            }                //根据Select语句自动生成其他SQL语句
            public void BuildAdapter(ref SqlDataAdapter adapter)
            {
                SqlCommandBuilder builder = new SqlCommandBuilder(adapter);
                adapter.DeleteCommand = builder.GetDeleteCommand();
                adapter.InsertCommand = builder.GetInsertCommand();
                adapter.UpdateCommand = builder.GetUpdateCommand();
            }
        }
    }
    然后我在解决方案中添加了bookshopDataSet.xsd这个数据集
    这是在窗口中的代码中调用这个组件:
    namespace TestComponent
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
                string connString =    Properties.Settings.Default.bookshopConnectionString;
                TestComponent.BookShop  me = new TestComponent.BookShop ();
                label1.Text = "总记录数:" + me.GetRecordCount(connString, "bookshop");
                SqlConnection conn = new SqlConnection(connString);
                SqlDataAdapter adapter = new SqlDataAdapter("select * from bookshop", conn);
                me.BuildAdapter(ref adapter);
                DataSet ds = new DataSet();
                adapter.Fill(ds, "bookshop");
                dataGridView1.DataSource = ds.Tables["bookshop"];        }        private void Form1_Load(object sender, EventArgs e)
            {
                // TODO: 这行代码将数据加载到表“bookshopDataSet.Book”中。您可以根据需要移动或移除它。
                this.bookTableAdapter.Fill(this.bookshopDataSet.Book);        }
        }
    }
    会有这样的出错误
     "无法直接启动带有"类库输出类型"的项目
       若要调试次项目,请在此就解决方案中添加一个引用库项目的可执行项目,将这个可执行项目 设置为启动项目"
      

  3.   

    SqlCommand command = new SqlCommand("select count(*)from" + tableName, conn);
    改成:SqlCommand command = new SqlCommand("select count(*) from" + tableName, conn);断续找..
      

  4.   

    错误大概是跟这个加入的数据集bookshopDataSet.xsd有关系
    我想要把原来的项目中的数据库文件进来,可是不知道如何将创建好的数据库保存成.mdf文件