保持一個DataSet,我在一個內部Web應用程序轉換爲的winform應用斷開連接的原因的過程中,我打下面的障礙。試圖在winform應用程序
在Function SaveMe()
上的Web應用程序存在Person.ascx.vb頁面下面的代碼 - >
//get dataset from session
Dim dsPerson As Data.DataSet = CType(Session.Item("Person" & Me.UniqueID), DataSet)
//if no rows in dataset, add
If dsPerson.Tables(0).Rows.Count = 0 Then
Dim rowPerson As Data.DataRow = dsPerson.Tables(0).NewRow
dsPerson.Tables(0).Rows.Add(FillPersonRow(rowPerson))
Else
//otherwise update
....more code here
我堅持上的部分是如何在邏輯上一個WinForm應用程序創建一個數據集?
如果我只是湊的所有字段,扔一個DataSet?如何(這是我將研究/時嘗試從SO等待諮詢)?
編輯
是越來越創建會話/填充在LoadMe()
子,像這樣 - >
//load person
Dim dsTemp As Data.DataSet = BLL.Person.GetPerson(PersonID)
//save to session state
Session.Add("Person" & Me.UniqueID, dsTemp)
編輯
我我要做的是創建一個表單級的變量 - >private DataSet _personInfo;
持有的數據集,然後在我的FormPaint(int personID)
我所說的以下內容:
_personInfo = ConnectBLL.BLL.Person.GetPerson(personID);
然後我用它來填充表單上的各個領域。
接下來,btnUpdate_Click()
我嘗試以下方法,但無濟於事:
void btnUpdate_Click(object sender, EventArgs e)
{
var areChanges = _personInfo.HasChanges();
if (areChanges)
{
var whatChanged = _personInfo.GetChanges();
var confirmChanges =
MessageBox.Show(
"Are you sure you want to make these changes: " +
whatChanged.Tables[0].Rows[0].ItemArray.ToString(), "Confirm Member Info Changes",
MessageBoxButtons.YesNo, MessageBoxIcon.Hand);
if (confirmChanges == DialogResult.Yes)
{
_personInfo.AcceptChanges();
ConnectBLL.BLL.Person.Update(_personInfo);
}
}
FormPaint(HUD.PersonId);
}
我不清楚是什麼,我做錯了什麼?我錯過了一步嗎?
謝謝
當你完成它時,isChanges是否爲false?如果是這樣,那麼您需要更新數據集中的值(手動或通過數據綁定)。 – 2009-08-05 22:42:14
是的,它每次都是假的...... – 2009-08-06 00:23:46