i created my Form programaticall using System.Reflaction. i want to add database with SubmitChanges. i will get data from whole txtbox and using any loop to fill Entity property. And than Submitchanges.
public static void Save( PlaceHolder Holder)
{
if (Holder.Controls.Count > 0)
{
foreach (Control item in Holder.Controls)
{
if (item is TextBox)
{
TextBox t1 = (TextBox)item;
if (t1.Text != "")
{
var engAccessData = new ENG_ACCESS()
{ENG_ACCESS_ACCESS_PANEL_NO = t1.Text //, don't any idea which Id is ok?
}
}
}
}
}
i know this. But how can i add txtbox's text value to
var stockMovement = new StockMovement
{
ENG_ACCESS_ACCESS_PANEL_NO = t1.Text,
TicketID = t2.Text,
ItemTypeNo = t3.Text,
StockCardID = t4.Text,
ItemID = t5.Text,
ItemBarcode = t6.Text,
};
stockMovementCtx.StockMovements.InsertOnSubmit(stockMovement);
stockMovementCtx.SubmitChanges();
I NEED THIS LIKE ADO.NET:
public bool AccessProcess(string sp, ListDictionary ld, CommandType cmdType)
{
SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["conn"].ToString());
SqlCommand cmd = new SqlCommand(sp, con);
try
{
con.Open();
cmd.CommandType = cmdType;
foreach (string ky in ld.Keys)
{
cmd.Parameters.AddWithValue(ky, ld[ky]);
}
cmd.ExecuteNonQuery();
}
finally
{
con.Dispose();
cmd.Dispose();
}
return true;
}
}
How to use like this linqto SQL ? or any method?
foreach (string ky in ld.Keys)
{
cmd.Parameters.AddWithValue(ky, ld[ky]);
}