まず、これらのフォーラムでのすべてのヘルプに感謝します。非常に役に立ちました。残念ながら、私にはよくわからない問題があります。他の人が見るメッセージを作成できるホームページを開くログイン画面を使用するプログラムを vb.net で作成しました。
新しいメッセージを作成できますが、プログラムを閉じて再度開かない限り、データグリッドビューに表示されません。それから彼らは存在しています。
Public Class frmMessage
Dim newMsgRow As Prototype1DataSet.MessagesRow
Dim editMsgRow As Prototype1DataSet.MessagesRow
Private Sub MessagesBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Me.Validate()
Me.MessagesBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.Prototype1DataSet)
End Sub
Private Sub MessageForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the Prototype1DataSet.Messages table. You can move, or remove it, as needed.'
Me.MessagesTableAdapter.Fill(Me.Prototype1DataSet.Messages)
End Sub
Private Sub btn_SaveMsg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_SaveMsg.Click
'Check if inputs are valid and then saves new message and returns to Home Page'
If CheckDataInputs() Then
If frmHomePage.editMsgFlag = False Then
SaveNewMessage()
ElseIf frmHomePage.editMsgFlag = True Then
EditMessage()
End If
MessageBox.Show("Message saved", Me.Text, MessageBoxButtons.OK)
Me.Hide()
frmHomePage.Show()
End If
End Sub
Private Function CheckDataInputs() As Boolean
'Check if any inputs are left empty'
Dim InputsCheck As Boolean = True
If txt_MsgFrom.Text = "" Then
MessageBox.Show("Please state whom the message is from", Me.Text, MessageBoxButtons.OK)
Me.txt_MsgFrom.Focus()
InputsCheck = False
ElseIf txt_MsgTo.Text = "" Then
MessageBox.Show("Please enter message recipient", Me.Text, MessageBoxButtons.OK)
Me.txt_MsgTo.Focus()
InputsCheck = False
ElseIf txt_Message.Text = "" Then
MessageBox.Show("Please enter a message", Me.Text, MessageBoxButtons.OK)
Me.txt_Message.Focus()
InputsCheck = False
ElseIf txt_MsgStatus.Text = "" Then
MessageBox.Show("Please select message status", Me.Text, MessageBoxButtons.OK)
Me.txt_Message.Focus()
InputsCheck = False
End If
Return InputsCheck
End Function
Private Sub SaveNewMessage()
'Saves new message into Messages table'
newMsgRow = Prototype1DataSet.Messages.NewMessagesRow()
newMsgRow.From = txt_MsgFrom.Text
newMsgRow._To = txt_MsgTo.Text
newMsgRow.Message = txt_Message.Text
newMsgRow.Status = txt_MsgStatus.Text
newMsgRow._Date = date_Msg.Text
Prototype1DataSet.Messages.AddMessagesRow(newMsgRow)
MessagesTableAdapter.Update(Prototype1DataSet)
Prototype1DataSet.Messages.AcceptChanges()
End Sub
End Class