PDA

View Full Version : مبتدی: علت آپدیت نشدن بانک اطلاعاتی اکسس



mononoor
سه شنبه 20 بهمن 1394, 19:07 عصر
با سلام خدمت دوستان
من از کد زیر استفاده کردم و درون جدول از بانک اطلاعاتی اکسس داده هایی را وارد کردم
مشکل اینجاست که وقتی می خوام این اطلاعات را آپدیت کنم پیام خطای زیر را می دهد
no value given for one or more required parameters
دوستان کسی هست کمک کنه به من
در ضمن من مبتدی هستم و این کد را از یک مثال دیگه که شبیه برنامه خودم بود با تغییراتی در برنامه خودم استفاده کردم. توی اون برنامه درست جواب میده ولی در برنامه من نه



Private Sub BSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BSave.Click

Main = FrmMain
If FormState = Form_State.Add_RecordState Then
If RequiredEntry() = True Then
Return
End If
Try

Dim DtaRow As DataRow

Dim MemStream As New MemoryStream
' Dim DataPic_Insert As Byte()

DtaRow = DtaSet.Tables("gabz").NewRow

With DtaRow
.Item("idghabz") = IIf(IDghabzTextBox.Text = "", System.DBNull.Value, IDghabzTextBox.Text)
.Item("datesefaresh") = IIf(DatesefareshDateTimePicker.Text = "", System.DBNull.Value, DatesefareshDateTimePicker.Text)
.Item("timesefaresh") = IIf(TimesefareshDateTimePicker.Text = "", System.DBNull.Value, TimesefareshDateTimePicker.Text)
.Item("idtaraf") = IIf(IdtarafTextBox.Text = "", System.DBNull.Value, IdtarafTextBox.Text)
.Item("nam") = IIf(NamTextBox.Text = "", System.DBNull.Value, NamTextBox.Text)
.Item("family") = IIf(FamilyTextBox.Text = "", System.DBNull.Value, FamilyTextBox.Text)
.Item("codemeli") = IIf(CodemeliTextBox.Text = "", System.DBNull.Value, CodemeliTextBox.Text)
.Item("tel") = IIf(TelTextBox.Text = "", System.DBNull.Value, TelTextBox.Text)
.Item("mobile") = IIf(MobileTextBox.Text = "", System.DBNull.Value, MobileTextBox.Text)
.Item("vajhekol") = IIf(VajhekolTextBox.Text = "", System.DBNull.Value, VajhekolTextBox.Text)
.Item("takhfifghabz") = IIf(TakhfifghabzTextBox.Text = "", System.DBNull.Value, TakhfifghabzTextBox.Text)

.Item("takhfiftot") = IIf(TakhfiftotTextBox.Text = "", System.DBNull.Value, TakhfiftotTextBox.Text)
.Item("biane") = IIf(BianeTextBox.Text = "", System.DBNull.Value, BianeTextBox.Text)
.Item("mandeh") = IIf(MandehTextBox.Text = "", System.DBNull.Value, MandehTextBox.Text)
.Item("iduser") = IIf(IduserTextBox.Text = "", System.DBNull.Value, IduserTextBox.Text)
.Item("shenasname") = IIf(ShenasnameTextBox.Text = "", System.DBNull.Value, ShenasnameTextBox.Text)
.Item("masir") = IIf(MasirTextBox.Text = "", System.DBNull.Value, MasirTextBox.Text)
.Item("sabt") = IIf(SabtCheckBox.Text = "", System.DBNull.Value, SabtCheckBox.Text)

' Me.PicStudent.Image.Save(MemStream, Imaging.ImageFormat.Jpeg)
' DataPic_Insert = MemStream.GetBuffer()
' MemStream.Read(DataPic_Insert, 0, MemStream.Length)

' .Item("StudentPic") = DataPic_Insert
End With

DtaSet.Tables("gabz").Rows.Add(DtaRow)

OleDa.Update(DtaSet, "gabz")
DtaSet.AcceptChanges()

'Focus the Added record...
With Main
.BindingContext.Item(DtaSet, "gabz").Position = Main.BindingContext.Item(DtaSet, "gabz").Count - 1
Call .Navigation()
End With

MsgBox("Record's successfully saved...", MsgBoxStyle.Information, "Record's saved...")
If MsgBox("Do you want to add new record?", MsgBoxStyle.Question + MsgBoxStyle.YesNo, "Confirmation...") = MsgBoxResult.Yes Then
Me.FormState = Form_State.Add_RecordState
Call ResetEntry()
IDghabzTextBox.Focus()
Exit Sub
End If
Me.Close()

Catch ex As Exception
MsgBox(ex.Message(), MsgBoxStyle.Exclamation, "Sorry, unable to save...")

'if Duplicate Student ID...
IDghabzTextBox.Focus()
IDghabzTextBox.SelectAll()
DtaSet.RejectChanges()
End Try
Exit Sub
End If

If FormState = Form_State.Edit_RecordState Then
If RequiredEntry() = True Then
Return
End If
Try

Dim MemStream As New MemoryStream
'Dim DataPic_Update As Byte()

With DtaSet2

.Tables("gabz").Rows(0).Item("idghabz") = IIf(IDghabzTextBox.Text = "", System.DBNull.Value, IDghabzTextBox.Text)
.Tables("gabz").Rows(0).Item("datesefaresh") = IIf(DatesefareshDateTimePicker.Text = "", System.DBNull.Value, DatesefareshDateTimePicker.Text)
.Tables("gabz").Rows(0).Item("timesefaresh") = IIf(TimesefareshDateTimePicker.Text = "", System.DBNull.Value, TimesefareshDateTimePicker.Text)
.Tables("gabz").Rows(0).Item("idtaraf") = IIf(IdtarafTextBox.Text = "", System.DBNull.Value, IdtarafTextBox.Text)
.Tables("gabz").Rows(0).Item("nam") = IIf(NamTextBox.Text = "", System.DBNull.Value, NamTextBox.Text)
.Tables("gabz").Rows(0).Item("family") = IIf(FamilyTextBox.Text = "", System.DBNull.Value, FamilyTextBox.Text)
.Tables("gabz").Rows(0).Item("codemeli") = IIf(CodemeliTextBox.Text = "", System.DBNull.Value, CodemeliTextBox.Text)
.Tables("gabz").Rows(0).Item("tel") = IIf(TelTextBox.Text = "", System.DBNull.Value, TelTextBox.Text)
.Tables("gabz").Rows(0).Item("mobile") = IIf(MobileTextBox.Text = "", System.DBNull.Value, MobileTextBox.Text)
.Tables("gabz").Rows(0).Item("vajhekol") = IIf(VajhekolTextBox.Text = "", System.DBNull.Value, VajhekolTextBox.Text)
.Tables("gabz").Rows(0).Item("takhfifghabz") = IIf(TakhfifghabzTextBox.Text = "", System.DBNull.Value, TakhfifghabzTextBox.Text)

.Tables("gabz").Rows(0).Item("takhfiftot") = IIf(TakhfiftotTextBox.Text = "", System.DBNull.Value, TakhfiftotTextBox.Text)
.Tables("gabz").Rows(0).Item("biane") = IIf(BianeTextBox.Text = "", System.DBNull.Value, BianeTextBox.Text)
.Tables("gabz").Rows(0).Item("mandeh") = IIf(MandehTextBox.Text = "", System.DBNull.Value, MandehTextBox.Text)
.Tables("gabz").Rows(0).Item("iduser") = IIf(IduserTextBox.Text = "", System.DBNull.Value, IduserTextBox.Text)
.Tables("gabz").Rows(0).Item("shenasname") = IIf(ShenasnameTextBox.Text = "", System.DBNull.Value, ShenasnameTextBox.Text)
.Tables("gabz").Rows(0).Item("masir") = IIf(MasirTextBox.Text = "", System.DBNull.Value, MasirTextBox.Text)
.Tables("gabz").Rows(0).Item("sabt") = IIf(SabtCheckBox.Text = "", System.DBNull.Value, SabtCheckBox.Text)



End With


BindingContext(DtaSet2, "gabz").EndCurrentEdit()
If DtaSet2.HasChanges() Then
OleDa.Update(DtaSet2, "gabz")
DtaSet2.AcceptChanges()
End If

'Focus updated record without load or refresh...
With Main
With .DgV
.SelectedRows(0).Cells(0).Value = Me.IDghabzTextBox.Text
.SelectedRows(0).Cells(1).Value = Me.DatesefareshDateTimePicker.Text
.SelectedRows(0).Cells(2).Value = Me.TimesefareshDateTimePicker.Text
.SelectedRows(0).Cells(3).Value = Me.IdtarafTextBox.Text
.SelectedRows(0).Cells(4).Value = Me.NamTextBox
.SelectedRows(0).Cells(5).Value = Me.FamilyTextBox.Text
.SelectedRows(0).Cells(6).Value = Me.CodemeliTextBox.Text
.SelectedRows(0).Cells(7).Value = Me.TelTextBox.Text
.SelectedRows(0).Cells(8).Value = Me.MobileTextBox.Text
.SelectedRows(0).Cells(9).Value = Me.VajhekolTextBox.Text
.SelectedRows(0).Cells(10).Value = Me.TakhfifghabzTextBox.Text
.SelectedRows(0).Cells(11).Value = Me.TakhfiftotTextBox.Text
.SelectedRows(0).Cells(12).Value = Me.BianeTextBox.Text
.SelectedRows(0).Cells(13).Value = Me.MandehTextBox.Text
.SelectedRows(0).Cells(14).Value = Me.IduserTextBox.Text
.SelectedRows(0).Cells(15).Value = Me.ShenasnameTextBox.Text
.SelectedRows(0).Cells(16).Value = Me.MasirTextBox.Text
.SelectedRows(0).Cells(17).Value = Me.SabtCheckBox.Text




End With
' .PictureBox1.Image = Me.PicStudent.Image
End With

MsgBox("Record's successfully updated...", MsgBoxStyle.Information, "Record's Updated...")
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, "Sorry, Unable to update...")

'If Duplicate Student ID Back to updated Student ID (Undo)
Me.IDghabzTextBox.Text = Main.DgV.SelectedRows(0).Cells(0).Value
End Try
Exit Sub
End If
End Sub