DAL Data Link Layer non-query/query
Using System;
Using System.Collections.Generic;
Using System.Linq;
Using System.Text;
Using System.Threading.Tasks;
Using System.Data;
Using System.Data.SqlClient;
Namespace DAL
{
public class SqlHelper//Non-query
{
public static int Baba (string sql,list<sqlparameter>paras)
{
SqlConnection conn = new SqlConnection ("server=.; Database=schoolido;uid=sa;pwd=123 ");
Conn. Open ();
SqlCommand cmd = new SqlCommand (SQL, conn);
Cmd. Parameters.addrange (paras. ToArray ());
return CMD. ExecuteNonQuery ();
}
}
}
public static DataTable name (String sql, list<sqlparameter> arr)
{
DataSet set = new DataSet ();
SqlConnection conn = new SqlConnection (); Querying a batch of values
Conn. Open ();
SqlCommand dx = new SqlCommand (SQL, conn);
Dx. Parameters.addrange (arr. ToArray ());
SqlDataAdapter haha = new SqlDataAdapter (DX);
haha. Fill (set);
return set. Tables[0];
}
public static object name (String sql, list<sqlparameter> arr)
{
SqlConnection conn = new SqlConnection ("");
SqlCommand dx = new SqlCommand (sql,conn); Querying a value
Dx. Parameters.Add (arr. ToArray ());
Return DX. ExecuteScalar ();
}
Three layer Architecture DAL layer Basic code non-query/query