这样的通用类和DAL代码是存储过程吗?
DAL//修改publicstaticboolUpdateStuInfo(StuInfostu){stringstrsql="updatestuInfoset"+"stu...
DAL
//修改
public static bool UpdateStuInfo(StuInfo stu)
{
string strsql = "update stuInfo set "
+"stuName = @stuName,"
+"stuAge = @stuAge,"
+"stuSex = @stuSex,"
+"stuAdress = @stuAdress where stuNo=@stuNo";
//strsql += ";@@identity";
SqlParameter[] para = new SqlParameter[]
{
new SqlParameter("@stuName",stu.stuName),
new SqlParameter("@stuNo",stu.stuNo),
new SqlParameter("@stuAge",stu.stuAge),
new SqlParameter("@stuSex",stu.stuSex),
new SqlParameter("@stuAdress",stu.stuAdress)
};
int count = DBHelper.ExecuteCommand(strsql,para);
if (count > 0)
{
return true;
}
else
{
return false;
}
}
public static int AddStu(StuInfo stu)
{
string strsql = "insert into stuInfo(stuName,stuNo,stuAge,stuSex,stuAdress)"+
"values(@stuName,@stuNo,@stuAge,@stuSex,@stuAdress)";
//strsql += ";@@identity";
SqlParameter[] para = new SqlParameter[]
{
new SqlParameter("@stuName",stu.stuName),
new SqlParameter("@stuNo",stu.stuNo),
new SqlParameter("@stuAge",stu.stuAge),
new SqlParameter("@stuSex",stu.stuSex),
new SqlParameter("@stuAdress",stu.stuAdress)
};
int result= DBHelper.ExecuteCommand(strsql,para);
return result;
}
}
通用类=================================
public static class DBHelper
{
private static SqlConnection connection;
public static SqlConnection Connection
{
get
{
string connectionString = ConfigurationManager.ConnectionStrings["MyOfficeConnectionString"].ConnectionString;
connection = new SqlConnection(connectionString);
if (connection == null)
{
connection.Open();
}
else if (connection.State == System.Data.ConnectionState.Closed)
{
connection.Open();
}
else if (connection.State == System.Data.ConnectionState.Broken)
{
connection.Close();
connection.Open();
}
return connection;
}
}
public static SqlDataReader GetReader(string safeSql)
{
SqlCommand cmd = new SqlCommand(safeSql, Connection);
SqlDataReader reader = cmd.ExecuteReader();
return reader;
reader.Close();
reader.Dispose();
} 展开
//修改
public static bool UpdateStuInfo(StuInfo stu)
{
string strsql = "update stuInfo set "
+"stuName = @stuName,"
+"stuAge = @stuAge,"
+"stuSex = @stuSex,"
+"stuAdress = @stuAdress where stuNo=@stuNo";
//strsql += ";@@identity";
SqlParameter[] para = new SqlParameter[]
{
new SqlParameter("@stuName",stu.stuName),
new SqlParameter("@stuNo",stu.stuNo),
new SqlParameter("@stuAge",stu.stuAge),
new SqlParameter("@stuSex",stu.stuSex),
new SqlParameter("@stuAdress",stu.stuAdress)
};
int count = DBHelper.ExecuteCommand(strsql,para);
if (count > 0)
{
return true;
}
else
{
return false;
}
}
public static int AddStu(StuInfo stu)
{
string strsql = "insert into stuInfo(stuName,stuNo,stuAge,stuSex,stuAdress)"+
"values(@stuName,@stuNo,@stuAge,@stuSex,@stuAdress)";
//strsql += ";@@identity";
SqlParameter[] para = new SqlParameter[]
{
new SqlParameter("@stuName",stu.stuName),
new SqlParameter("@stuNo",stu.stuNo),
new SqlParameter("@stuAge",stu.stuAge),
new SqlParameter("@stuSex",stu.stuSex),
new SqlParameter("@stuAdress",stu.stuAdress)
};
int result= DBHelper.ExecuteCommand(strsql,para);
return result;
}
}
通用类=================================
public static class DBHelper
{
private static SqlConnection connection;
public static SqlConnection Connection
{
get
{
string connectionString = ConfigurationManager.ConnectionStrings["MyOfficeConnectionString"].ConnectionString;
connection = new SqlConnection(connectionString);
if (connection == null)
{
connection.Open();
}
else if (connection.State == System.Data.ConnectionState.Closed)
{
connection.Open();
}
else if (connection.State == System.Data.ConnectionState.Broken)
{
connection.Close();
connection.Open();
}
return connection;
}
}
public static SqlDataReader GetReader(string safeSql)
{
SqlCommand cmd = new SqlCommand(safeSql, Connection);
SqlDataReader reader = cmd.ExecuteReader();
return reader;
reader.Close();
reader.Dispose();
} 展开
1个回答
光点科技
2023-08-15 广告
2023-08-15 广告
通常情况下,我们会按照结构模型把系统产生的数据分为三种类型:结构化数据、半结构化数据和非结构化数据。结构化数据,即行数据,是存储在数据库里,可以用二维表结构来逻辑表达实现的数据。最常见的就是数字数据和文本数据,它们可以某种标准格式存在于文件...
点击进入详情页
本回答由光点科技提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询