我在web應用程序中使用dll(NEWDAO.dll)。它有一個CS文件,我可以訪問類名的Web應用程序,但它不來有什麼問題,請給我任何建議我在web應用程序中添加了dll,但該dll無法訪問類名是什麼問題?
在NEWDAO名字空間類被DBConnection的代碼是
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Data;
namespace NEWDAO
{
class DbConnection
{
private int _EmpName;
private string _Name;
private decimal _Salary;
private DateTime _CreatedDate;
public bool Flag = false;
DataSet ds = new DataSet();
SqlConnection m_Con = new SqlConnection("Server=*******,dataSource=Test,user name=sa,password=*******");
SqlCommand m_Cmd = new SqlCommand();
public int EmpNo
{
get
{
return _EmpName;
}
set
{
_EmpName = value;
}
}
public string Name
{
get
{
return _Name;
}
set
{
_Name = value;
}
}
public decimal Salary
{
get
{
return _Salary;
}
set
{
_Salary = value;
}
}
public DateTime CreatedDate
{
get
{
return _CreatedDate;
}
set
{
_CreatedDate = value;
}
}
/// <summary>
/// Insert the Emp values
/// </summary>
public bool EmpInsert()
{
Flag = false;
m_Con.Open();
SqlCommand m_Cmd = new SqlCommand("usp_EmpInsert", m_Con);
m_Cmd.CommandType = CommandType.StoredProcedure;
m_Cmd.Parameters.AddWithValue("@EmpName", EmpNo);
m_Cmd.Parameters.AddWithValue("@Name", Name);
m_Cmd.Parameters.AddWithValue("@Salary", Salary);
m_Cmd.Parameters.AddWithValue("@CreatedDate", CreatedDate);
if (m_Cmd.ExecuteNonQuery() >= 0)
{
Flag = true;
return Flag;
}
else
{
return Flag;
}
m_Con.Close();
}
/// <summary>
/// Display the values
/// </summary>
public bool EmpSelect(out DataSet oDS)
{
Flag = false;
m_Con.Open();
SqlCommand m_Cmd = new SqlCommand("usp_EmpInsert", m_Con);
m_Cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter ad = new SqlDataAdapter("usp_EmpInsert", m_Con);
ad.Fill(ds, "EMP");
if (ds != null)
{
oDS = ds;
Flag = true;
return Flag;
}
else
{
oDS = null;
return Flag;
}
m_Con.Close();
}
}
}
謝謝 hemanth
你是如何將這個DLL添加到你的Web應用程序? –
您確定您嘗試使用的課程是公開的嗎? – MattDavey
添加參考瀏覽選擇使用DAO添加.aspx.cs文件後的DLL也 – hmk