gpt4 book ai didi

database - 更新数据库的问题

转载 作者:搜寻专家 更新时间:2023-10-30 20:53:39 25 4
gpt4 key购买 nike

我已附上代码以供引用。我正在尝试为我的项目详细信息创建数据库。我目前有 2 种形式:

  1. 主窗体
  2. 项目详细信息表

主窗体用于切换各种窗体

项目详细信息表单用于添加/编辑/加载项目详细信息

我在 visual basic 中的主窗体是这样的。

Public Class Form1

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub

Private Sub Bt_Project_Details_Click(sender As Object, e As EventArgs) Handles Bt_Project_Details.Click
Me.Hide()
Project_Details_Form.Show()
End Sub
End Class

我的项目详细信息表单如下所示。

Public Class Project_Details_Form

Private Sub Project_Details_Form_Load(sender As Object, e As EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'Project_Data_Set.Project_Data_Table' table. You can move, or remove it, as needed.
Me.Project_Data_TableTableAdapter.Fill(Me.Project_Data_Set.Project_Data_Table)
End Sub

Private Sub Bt_Load_Project_Click(sender As Object, e As EventArgs) Handles Bt_Load_Project.Click
End Sub

Private Sub Bt_Cancel_Click(sender As Object, e As EventArgs) Handles Bt_Cancel.Click
Me.Hide()
Form1.Show()
End Sub

Private Sub BindingNavigatorAddNewItem_Click(sender As Object, e As EventArgs) Handles BindingNavigatorAddNewItem.Click
Project_Data_TableBindingSource.AddNew()
End Sub

Private Sub Project_Data_TableBindingNavigatorSaveItem_Click(sender As Object, e As EventArgs) Handles Project_Data_TableBindingNavigatorSaveItem.Click
Me.Validate()
Me.Project_Data_TableBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.Project_Data_Set)
End Sub

Private Sub BindingNavigatorDeleteItem_Click(sender As Object, e As EventArgs) Handles BindingNavigatorDeleteItem.Click
Project_Data_TableBindingSource.RemoveCurrent()
End Sub

Private Sub FillByToolStripButton_Click(sender As Object, e As EventArgs)
Try
Me.Project_Data_TableTableAdapter.FillBy(Me.Project_Data_Set.Project_Data_Table)
Catch ex As System.Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try

End Sub
End Class

现在我面临着几个问题:

  1. 每当我运行程序时,尝试输入正在保存但值为空的第一个条目数据。下次输入的数据妥善保存。如何让我的第一个条目可见?

  2. 在下面的代码中:

    Private Sub BindingNavigatorAddNewItem_Click(sender As Object, e As EventArgs) Handles BindingNavigatorAddNewItem.Click
    Project_Data_TableBindingSource.AddNew()

    End Sub

    我正在使用 AddNew()。这工作正常,但问题是即使我不输入日期之类的数据,名称保持为空,记录在他们位置的数据仅存储为空。我想说的是,如果任何项目数据集为空,则给出错误消息(因为用户必须输入这些数据)

最佳答案

有没有其他方法可以单独赋值。就像我的项目数据库包含项目名称、客户名称等。如果我说按下新按钮清除所有字段。一旦按下保存按钮,填写表格后将记录单个值

Private Sub BindingNavigatorAddNewItem_Click(sender As Object, e As EventArgs) Handles BindingNavigatorAddNewItem.Click
Project_Data_TableBindingSource.AddNew()
End Sub

关于database - 更新数据库的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32307281/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com