public
class
HomeController : Controller
{
public
ActionResult Index()
{
#region connect sql
function
one
SqlConnectionStringBuilder one =
new
SqlConnectionStringBuilder();
one.DataSource =
"(local)\\sqlexpress"
;
one.InitialCatalog =
"xsgl1"
;
one.UserID =
"sa"
;
one.Password =
"a123456"
;
one.MaxPoolSize = 512;
SqlConnection sct =
new
SqlConnection(one.ConnectionString);
#endregion
#region connect sql
function
two
#endregion
#region connect sql
function
three
#endregion
SqlCommand scm =
new
SqlCommand();
scm.Connection = sct;
scm.CommandType = CommandType.Text;
scm.CommandText =
"SELECT 课程名 from kc where 课程号='A001'"
;
sct.Open();
SqlDataReader sdr = scm.ExecuteReader();
if
(sdr.Read())
{
ViewBag.hao = sdr[
"课程名"
];
}
sdr.Close();
return
View();
}
public
ActionResult About()
{
return
View();
}
}
Controller