这是我一直在 VB.net 中做的事情,我正试图在 c# 中复制它。基本上我有一个连接到 sqlserver 的数据集,我正在尝试添加一个新行。我有以下内容,但 rMainPID 似乎为空。
private components.db.PIDSDB.MainPIDDataTable dtMainPID;
private components.db.PIDSDBTableAdapters.MainPIDTableAdapter taMainPID = new components.db.PIDSDBTableAdapters.MainPIDTableAdapter();
然后主要:
protected void doSave(object sender, EventArgs e)
{
Int32 ClientID = Convert.ToInt32(txtCompanyClientID.Text);
String ChannelLead = Request.Form["ChannelLead"];
// String ChannelSalesPerson = Request.Form["ChannelSalesPerson"];
String ChannelSalesPerson = "Test";
String DropDeadDate = Request.Form["DropDeadDate"];
String MCSalesLead = Request.Form["MCSalesLead"];
Int32 ProjectTypeID = Convert.ToInt32(Request.Form["ProjectTypeID"]);
Int32 ProjectStatusID = Convert.ToInt32(Request.Form["ProjectStatusID"]);
String ClientBriefing = Request.Form["ClientBriefing"];
String ProjectRequirements = txtProjectRequirements.Text;
components.db.PIDSDB.MainPIDRow rMainPID = default(components.db.PIDSDB.MainPIDRow);
rMainPID = dtMainPID.NewMainPIDRow();
rMainPID.ClientID = (ClientID);
rMainPID.ChannelLead = (ChannelLead);
rMainPID.ChannelSalesPerson = (ChannelSalesPerson);
rMainPID.DropDeadDate = (DropDeadDate);
rMainPID.MCSalesLead = (MCSalesLead);
rMainPID.ProjectTypeID = (ProjectTypeID);
rMainPID.ProjectStatusID = (ProjectStatusID);
rMainPID.ClientBriefing = (ClientBriefing);
rMainPID.ProjectRequirements = (ProjectRequirements);
dtMainPID.AddMainPIDRow(rMainPID);
taMainPID.Update(dtMainPID);
}