我使用Microsoft Visual C#2010 express来编写表单程序来读取和写入访问数据库。我创建的dll文件的C#引用不起作用,因为它应该
我创建了一个类,用于读写数据库文件,将其保存在命名空间下并从中创建一个dll。
它被设置为” .NET框架4"
在我的主程序我加入了参考dll文件,但是当我试图把它与
using Database;
添加到代码中它赢得即使数据库存在于命名空间的引用中也无法工作。
我做错了什么?还是有另一种方法来使用我的主程序中的数据库命令,然后将其复制到它?
//更新// 解决 已公开添加到所有数据库公共和DataBase db = new DataBase();
DATABASE.cs是用它的dll
using System;
using System.Collections.Generic;
using System.Data.OleDb;
namespace Database
{
public class DataBase
{
public DataBase()
{
}
public void ItemInsert(string name,string creator,string publishing,string itemType,string genere, string year)
主程序
using System;
using System.Windows.Forms;
using Database;
namespace library
{
public partial class newItemForm : Form
{
private void btnConfirmNewItemClick(object sender, EventArgs e)
{
DataBase db = new DataBase(); //this solved it
db.ItemInsert(txtItemNameType.Text, txtEditorType.Text, txtCreatorType.Text, comboBoxType.Text, txtGenereType.Text, txtYearType.Text);
}
}
}
什么是您尝试使用的类型的全名?名称并包含命名空间 – JaredPar 2012-03-06 17:35:05
您试图在名称空间数据库中使用'public'的类? – 2012-03-06 17:35:30
@ user501160,请用你的数据库类文件中的2行更新你的问题:'namespace XXXXX'和'??? class Database“,因此可以提出更好的建议。顺便说一句,添加命名空间的更简单的方法是键入类名,并让VisualStudio通过单击源中类名旁边的小矩形来添加命名空间本身。 – 2012-03-06 17:39:03