我在项目中添加一个组件,然后导入一个数据库,运行出现下面的警告警告 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问题处在哪里了呢
解决方案 »
- 水晶报表问题 离散值多值情况
- wcf使用nettcp代码调用报错!
- c#中如果实现了icomparable接口是不是一调用他的实现类就默认调用他的方法
- 在C# 中对于code39码的44个字符, 用条形扫描枪扫不出来星号(×)和加号(+)?高分求就!!!
- 如何用代码控制DataGridView的内容进行滚动?
- 请问,如何在创建excel图表时指定它所属的SHEET
- 为什么以下代码在vs2003测试通过而在vs2005不能通过?????????
- 关于网络延迟测试
- 安装C#出现问题
- 可以动态编辑HTML文件的控件,支持可视效果和源码编辑两种模式。
- 上传文件到服务器问题
- c#求救:老是說該a 'property' where a 'method' was expected!!why??
丢个code出来啦, 这样看死人呢
这是组件的代码: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); }
}
}
会有这样的出错误
"无法直接启动带有"类库输出类型"的项目
若要调试次项目,请在此就解决方案中添加一个引用库项目的可执行项目,将这个可执行项目 设置为启动项目"
改成:SqlCommand command = new SqlCommand("select count(*) from" + tableName, conn);断续找..
我想要把原来的项目中的数据库文件进来,可是不知道如何将创建好的数据库保存成.mdf文件