09-11-20, 07:54 PM
جملة التحميل
جملة الحفظ
استخدم الكود المرفق فقط عدل اسم الجدول والحقول واسم الجرد فيو لعرض البيانات عليها
وهذا الكود من خلف Button
بالتوفيق ان شاء الله
كود :
Public Sub LoadAllTable_Table1_InDirect()
Dim dt As New DataTable
Dim da As New OleDbDataAdapter
dt.Clear()
da = New OleDbDataAdapter("select * from Table1", con)
da.Fill(dt)
End Subكود :
Public Sub Save_Table1_InDirect(colName As String, colNametxt As String)
' check if this ColumnName is already exist in database
Dim dt As New DataTable
Dim da As New OleDbDataAdapter
dt.Clear()
DA = New OleDbDataAdapter("Select * FROM Table1 where " & colName & " = '" & colNametxt & "'", con)
da.Fill(dt)
' if Column present give msgbox to alert & Dont save
If DT.Rows.Count > 0 Then
MsgBox("هذا الاسم موجود من قبل ", MsgBoxStyle.Critical, "بيانات مكررة")
Else
DT.Rows.Add()
Dim last As Integer = DT.Rows.Count - 1
DT.Rows(last).Item("ID") = ID.Text
DT.Rows(last).Item("name1") = name1.Text
Dim Save As New OleDbCommandBuilder(DA)
DA.Update(DT)
DT.AcceptChanges()
'give msgbox to sure save
MsgBox("تم الحفظ بنجاح ", MsgBoxStyle.Information, "تاكيد الحفظ")
' load table to refresh data
LoadAllTable_Table1_InDirect(dgv)
End If
End Subاستخدم الكود المرفق فقط عدل اسم الجدول والحقول واسم الجرد فيو لعرض البيانات عليها
وهذا الكود من خلف Button
كود :
Try
Save_Table1_InDirect("id", ID.Text)
Catch ex As Exception
MsgBox(ex.Message)
End Tryبالتوفيق ان شاء الله
