I am using a dll(NEWDAO.dll) in web application. It has a cs file, I can access that class name in web application but it is not came what is the problem, pls give me any suggestion
in NEWDAO name space class is DBConnection code is
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>
开发者_C百科 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();
}
}
}
thank you hemanth
You should also check to see if your class is public. The default access modifier is internal.
Class should be public to access from another assembly. Internal is the default if no access modifier is specified.
Set the class as public (
public class DbConnection
)Add reference to your dll
you can access this class as bellow
NEWDAO.DbConnection
Or you can add a using directives (using NEWDAO;
) and access DbConnection
directly
Maybe your application is targeting a different target framework than the assemblie. E.g. for a WPF Project, check
Properties -> Application -> Target Framework
Possible your DLL requires the full framework and your app is only targeting the client profile.
You need to add a using
directive that has the namespace where this class exists in, or use the full name, including the namespace.
So, if the full class name is:
DAO.SourceWordDoc
Either add a:
using DAO;
Or use the full name - DAO.SourceWordDoc
.
精彩评论