一个简单三层的问题

Tonglu 2003-10-10 11:07:06
现有a.cs,与b.cs
在a.cs中用到了b.cs中的参数
b.cs编译成功生成了b.dll
但a.cs编译时即出错提示找不到b.dll里面那个相应的参数


错误提示:
是否使用了useing 但程序中使用了
(保证程序没有错误,因为是微软件quickstars里面的程序只是编译时出错)

难道在三层中编译dll文件还需要其它设置吗?

...全文
100 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
mongtze 2003-10-10
  • 打赏
  • 举报
回复
把 b.dll 放在 BIN目录里,然后在项目里边添加引用 b.dll
Tonglu 2003-10-10
  • 打赏
  • 举报
回复
忘大侠帮忙!万分感谢!
Tonglu 2003-10-10
  • 打赏
  • 举报
回复
这是被调用的页面

using System.Reflection;

[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("A QuickStart Tutorial Assembly")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyProduct("Microsoft QuickStart Tutorials")]
[assembly: AssemblyCopyright(" Microsoft Corporation. All rights reserved.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("1.1.*")]

namespace DataLayer
{
using System;
using System.Data;
using System.Data.SqlClient;

public class DataObj
{
private String _connStr;

public DataObj()
{
_connStr = null;
}

public DataObj(String connStr)
{
_connStr = connStr;
}

public String ConnectionString
{
get
{
return _connStr;
}
set
{
_connStr = value;
}
}

public DataView GetCategories()
{
SqlConnection myConnection = new SqlConnection(_connStr);
SqlDataAdapter myCommand = new SqlDataAdapter("select distinct CategoryName from Categories", myConnection);

DataSet ds = new DataSet();
try
{
myCommand.Fill(ds, "Categories");

return ds.Tables["Categories"].DefaultView;
}
catch (Exception ex)
{
throw (ex);
}
finally
{
myConnection.Close();
}
}

public DataView GetProductsForCategory(String category)
{
SqlConnection myConnection = new SqlConnection(_connStr);
SqlDataAdapter myCommand = new SqlDataAdapter("select ProductName, ImagePath, UnitPrice, c.CategoryId from Products p, Categories c where c.CategoryName='" + category + "' and p.CategoryId = c.CategoryId", myConnection);

DataSet ds = new DataSet();
try
{
myCommand.Fill(ds, "Products");

return ds.Tables["Products"].DefaultView;
}
catch (Exception ex)
{
throw (ex);
}
finally
{
myConnection.Close();
}
}
}

}

Tonglu 2003-10-10
  • 打赏
  • 举报
回复
这是调用的页面

using System.Reflection;

[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("A QuickStart Tutorial Assembly")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft Corporation")]
[assembly: AssemblyProduct("Microsoft QuickStart Tutorials")]
[assembly: AssemblyCopyright(" Microsoft Corporation. All rights reserved.")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("1.1.*")]

namespace BusinessLayer
{
using System;
using System.Data;
using System.Data.SqlClient;
using DataLayer;

public class BusObj
{
private DataObj data;

public BusObj()
{
data = new DataObj("server=187.186.0.52;uid=sa;pwd=;database=grocertogo");
}

public DataView GetCategories()
{
return data.GetCategories();
}

public DataView GetProductsForCategory(String category, int customerid)
{
DataView view = data.GetProductsForCategory(category);

double discount = 0;
if ((customerid >= 25)&&(customerid < 50))
{
discount = .50;
}
else if ((customerid >= 50)&&(customerid < 75))
{
discount = 1.00;
}
else if ((customerid >= 75)&&(customerid < 100))
{
discount = 1.50;
}

for (int i=0; i<view.Count; i++)
{
view[i]["UnitPrice"] = Double.Parse(view[i]["UnitPrice"].ToString()) - discount;
}

return view;
}
}

}


cqnetboy 2003-10-10
  • 打赏
  • 举报
回复
在项目的引用加入b.dll文件
2002pine 2003-10-10
  • 打赏
  • 举报
回复
估计你是命名空间用错了,
你把你调用b.dll的代码贴出来,看一下,b.cs的命名空间。
Tonglu 2003-10-10
  • 打赏
  • 举报
回复
真的没人了解吗?
Tonglu 2003-10-10
  • 打赏
  • 举报
回复
顺便问一下,我每次都在DOS下编译很麻烦有没有简单的编译方法?谢谢,来者有分!
2002pine 2003-10-10
  • 打赏
  • 举报
回复
data = new DataObj("server=187.186.0.52;uid=sa;pwd=;database=grocertogo");
-->
data=new DataLayer.DataObj("server=187.186.0.52;uid=sa;pwd=;database=grocertogo");


或者using DataLayer;
sgsh51 2003-10-10
  • 打赏
  • 举报
回复
右健点击你的项目-〉项目依赖性-〉在你要依赖的项目上打上钩就可以了

1,178

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 数据库及相关技术
社区管理员
  • 数据库及相关技术社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧