0
我想在一個DataTable中添加新類型化的行和更新的源代碼,但它不工作.NET數據集不是新行更新
public partial class JobTableAdapter
{
public OpenMassSenderCore.OpenMassSenderDBDataSet.JobRow getNewRow()
{
return OpenMassSenderDBDataSet.getInstance().Job.NewJobRow();
}
public void submitRow(OpenMassSenderCore.OpenMassSenderDBDataSet.JobRow row)
{
OpenMassSenderDBDataSet.getInstance().Job.Rows.Add(row);
OpenMassSenderDBDataSet.getInstance().Job.AcceptChanges();
Update(OpenMassSenderDBDataSet.getInstance().Job);//thats the default tableadapter's update
}
private static JobTableAdapter instance;
public static JobTableAdapter getInstance()
{
if (instance == null) instance = new JobTableAdapter();
return instance;
}
}
private void button1_Click(object sender, EventArgs e)
{
OpenMassSenderCore.OpenMassSenderDBDataSet.JobRow job=JobTableAdapter.getInstance().getNewRow();
job.ID = 2;
job.query = "";
job.group = "smaplist1";
job.sender_account = 1;
job.status = OpenMassSenderCore.OpenMassSenderDBDataSet.JobRow.JobStatus.PENDING;
job.user = 1;
job.message =1;
JobTableAdapter.getInstance().submitRow(job);
}
如果我按下按鈕兩次,我拿到鑰匙(ID)現有的異常,所以這部分工作正常,唯一的問題是,它不更新數據庫(訪問)
似乎我的代碼產量「我是一個JAVA DEV」:),我想你的意思是單身的get方法... 。至於數據集,這是一個學校項目,我的教授希望我們使用它。 – SteveL