Hi ronaldlour,
Please refer below sample.
Controller
public ActionResult Submit()
{
string con1 = DBConnection.GetConn1();
string con2 = DBConnection.GetConn2();
string con3 = DBConnection.GetConn3();
string con4 = DBConnection.GetConn4();
return View();
}
HTML
@using (Html.BeginForm("Submit", "Home", FormMethod.Post))
{
<input type="submit" value="Submit" />
}
DBConnection
public static class DBConnection
{
public static string GetConn1()
{
return ".\\SQL2019;Initial Catalog=Northwind;Integrated Security=true";
}
public static string GetConn2()
{
return ".\\SQL2019;Initial Catalog=AjaxSamples;Integrated Security=true";
}
public static string GetConn3()
{
return ".\\SQL2019;Initial Catalog=Sample;Integrated Security=true";
}
public static string GetConn4()
{
return ".\\SQL2019;Initial Catalog=dbFiles;Integrated Security=true";
}
}
Screenshot