Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'هذا كود الاضافة
- If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" Then
- MsgBox("Please Enter All Informations...", MsgBoxStyle.Critical, Title:="Error")
- Else
- Try
- Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & My.Application.Info.DirectoryPath.ToString() & "\Database.accdb;")
- Dim insert As String = "Insert into Users values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "');"
- Dim cmd As New OleDbCommand(insert, conn)
- conn.Open()
- cmd.ExecuteNonQuery()
- MsgBox("New User Added Successfully", MsgBoxStyle.Information, Title:="Add New User Sucess")
- Me.Close()
- Catch ex As Exception
- MsgBox("Error", MsgBoxStyle.Critical, Title:="Error")
- End Try
- End If
- 'Public Class Form1 وهذا الكود ضعه فوق كلمة
- Imports System.Data.OleDb
- '======================================================================================================================
- '======================================================================================================================
- '======================================================================================================================
- 'هذا كود التعديل
- Dim cmd As New OleDbCommand
- Dim i As Integer
- con.Open()
- With cmd
- .Connection = con
- .CommandText = "UPDATE Sales SET ItemName = '" & ComboBox1.Text & "',ItemPrice = '" & TextBox1.Text & "',Quantity = '" & TextBox2.Text & "',Total = '" & TextBox3.Text & "',DateofSale = '" & TextBox4.Text & "'"
- i = .ExecuteNonQuery
- End With
- If i > 0 Then
- MsgBox("Update Record")
- End If
- con.Close()
- 'End Sub هذا فنكشن حطه تحت اي كلمة
- Public Function jokendb() As OleDb.OleDbConnection
- Return New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\Database.accdb")
- End Function
- 'Public Class Form1 وهذا الكود حطه تحت كلمة
- Public con As OleDb.OleDbConnection = jokendb()
- '======================================================================================================================
- '======================================================================================================================
- '======================================================================================================================
- 'هذا كود الحذف
- Dim con As OleDbConnection
- Dim com As OleDbCommand
- con = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & My.Application.Info.DirectoryPath.ToString() & "\Database.accdb")
- com = New OleDbCommand("delete from Users where Username = @Username", con)
- con.Open()
- com.Parameters.AddWithValue("@Username", TextBox1.Text)
- com.ExecuteNonQuery()
- MsgBox("User Deleted Sucessfully.", MsgBoxStyle.Information, Title:="User Deleted")
- con.Close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement