保持一个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