i get the error <pre>'ExecuteScalar: Connection property has not been initialized.'
this is what i tried controller string constring = ConfigurationManager.ConnectionStrings["DbContext"].ToString(); SqlConnection con = new SqlConnection(constring); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "SELECT MAX(Product_Code)+1 As Product_Code FROM Add_Product"; con.Open(); ViewBag.name = cmd.ExecuteScalar().ToString(); con.Close(); DBContext DB = new DBContext(); Create View <pre> @Html.TextBox("txtTitle", (string)ViewBag.name)
IDENTITY
SEQUENCE
SqlCommand cmd = new SqlCommand(); cmd.Connection = con; // add this
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)