问题描述
namespace BusinessAccessLayer
{
public class logiclayer
{
String Admisson_Number, First_Name, Last_Name, Father_Name, Mother_Name, Caste, Occupation, Parent_Mobilenumber,
Village_Name, District_Name, Street_Name, House_Number, Photo_Path;
DateTime Dateof_Birth, Dateof_Joining;
int Branch_Id, Gender_Id, Section_Id, State_Id, Country_Id, Religion_Id, Yearsof_Course, Pincode, Academic_Year;
logiclayer ObjDal = new logiclayer();
public string PAdmission_Number
{
set { Admisson_Number = value; }
get { return Admisson_Number; }
}
public string PFirst_Name
{
set { First_Name = value; }
get { return First_Name; }
}
public string PLast_Name
{
set { Last_Name = value; }
get { return Last_Name; }
}
public string PFather_Name
{
set { Father_Name = value; }
get { return Father_Name; }
}
命名空间DataAccessLayer
{
公共类ClsDalLayer
{
SqlConnection Con = new SqlConnection(ConfigurationManager.ConnectionStrings [ConnectionString]。ConnectionString);
ClsDalLayer Objdal = new ClsDalLayer();
public void DalRegistration()
{
SqlCommand Cmd = new SqlCommand(Sp_InsertStudentDetails,Con);
Cmd.Parameters.AddWithValue(@ Admission_Number,Objdal。); //在这里我无法访问类逻辑层的属性为什么?
如何编写代码将代码插入数据库帮帮我
提前谢谢
namespace DataAccessLayer
{
public class ClsDalLayer
{
SqlConnection Con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
ClsDalLayer Objdal = new ClsDalLayer();
public void DalRegistration()
{
SqlCommand Cmd = new SqlCommand("Sp_InsertStudentDetails", Con);
Cmd.Parameters.AddWithValue("@Admission_Number",Objdal.);// here i could not access the properties of the class logiclayer why?
how to write code to insert code into database Help me out
Thanks in advance
推荐答案
using BusinessAccessLayer;
namespace DataAccessLayer
{
public class ClsDalLayer
{
SqlConnection Con = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
logiclayer Objbal = new logiclayer();
public void DalRegistration()
{
try
{
SqlCommand Cmd = new SqlCommand("Sp_InsertStudentDetails", Con);
Cmd.Parameters.AddWithValue("@Admission_Number",Objbal.PAdmission_Number)
Cmd.Parameters.AddWithValue("@Admission_Number",Objbal.PFirst_Name)
Cmd.Parameters.AddWithValue("@Admission_Number",Objbal.PLast_Name)
Cmd.Parameters.AddWithValue("@Admission_Number",Objbal.PFather_Name)
Con.open();
Cmd.ExecuteNonQuery();
}
catch(Exception ex)
{
}
finally
{
Con.Close();
}
}
这篇关于为什么阶级属性在这里不可访问?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!