27-05-20, 07:53 PM
(27-05-20, 07:40 PM)معاند الحظ كتب : [ -> ]استبدل الاجرائين Insert_Table1 و Update_Table1 لديك بالتالي
كود :
Public Sub Insert_Table1()
Dim Cmd As New OleDbCommand
With Cmd
.Connection = con
.CommandType = CommandType.Text
.CommandText = "Insert Into Table1 (Dtp_ex,Dtp_CH)values(@Dtp_ex,@Dtp_CH)"
.Parameters.Clear()
If Dtp_ex.Checked Then
.Parameters.AddWithValue("@Dtp_ex", Dtp_ex.Value.ToString("yyyy/MM/dd"))
Else
.Parameters.AddWithValue("@Dtp_ex", DBNull.Value)
End If
.Parameters.AddWithValue("@Dtp_CH", Dtp_ex.Checked)
End With
If con.State = 1 Then con.Close()
con.Open()
Cmd.ExecuteNonQuery()
con.Close()
MsgBox("تم إضافة السجل بنجاح", MsgBoxStyle.Information, "حفظ")
Cmd = Nothing
End Sub
Public Sub Update_Table1()
Dim Cmd As New OleDbCommand
With Cmd
.Connection = con
.CommandType = CommandType.Text
.CommandText = "Update Table1 Set Dtp_ex = @Dtp_ex,Dtp_CH = @Dtp_CH Where ID = @ID"
.Parameters.Clear()
If Dtp_ex.Checked Then
.Parameters.AddWithValue("@Dtp_ex", Dtp_ex.Value.ToString("yyyy/MM/dd"))
Else
.Parameters.AddWithValue("@Dtp_ex", DBNull.Value)
End If
.Parameters.AddWithValue("@Dtp_CH", Dtp_ex.Checked)
.Parameters.AddWithValue("@ID", TextBox1.Text)
End With
If con.State = 1 Then con.Close()
con.Open()
Cmd.ExecuteNonQuery()
con.Close()
MsgBox("تم تعديل السجل بنجاح", MsgBoxStyle.Information, "تعديل")
Cmd = Nothing
End Sub
شكرا جزيلا أخي لقد نجح وعملت بهذا الكود بارك الله فيك وفي كل من ساعدني
كود :
If Dtp_ex.Checked = False Then
.Parameters.AddWithValue("@Dtp_ex", SqlDbType.NVarChar).Value = DBNull.Value
Else
.Parameters.AddWithValue("@Dtp_ex", Dtp_ex.Value.ToString("yyyy/MM/dd"))
End If