Public Sub delpk(dbpath As String, tbname As String, ColName As String, Optional dbpass As String = "")
Using con As New OleDb.OleDbConnection(constr(dbpath, dbpass))
Using cm As New OleDb.OleDbCommand("", con)
cm.CommandText = "ALTER TABLE " & tbname & " DROP Constraint " & tbname & "_pk;"
If con.State = ConnectionState.Closed Then con.Open()
Try
cm.ExecuteNonQuery()
MsgBox("تم حذف المفتاح")
Catch ex As Exception
MsgBox(Err.Description, MsgBoxStyle.Critical, "Error")
End Try
If con.State = ConnectionState.Open Then con.Close()
End Using
End Using
End Sub
Public Sub addpk(dbpath As String, tbname As String, ColName As String, Optional dbpass As String = "")
Using con As New OleDb.OleDbConnection(constr(dbpath, dbpass))
Using cm As New OleDb.OleDbCommand("", con)
cm.CommandText = "ALTER TABLE " & tbname & " ADD Constraint " & tbname & "_pk PRIMARY KEY (" & ColName & ");"
If con.State = ConnectionState.Closed Then con.Open()
Try
cm.ExecuteNonQuery()
MsgBox("تم اضافة المفتاح")
Catch ex As Exception
MsgBox(Err.Description, MsgBoxStyle.Critical, "Error")
End Try
If con.State = ConnectionState.Open Then con.Close()
End Using
End Using
End Sub