hi
I have successfuly created an access database with vb.net accept it is not password protected.
Can someone help me to password protect this DB.
Here is the code I use.
Thank you

Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
        Try
            Dim cat As New ADOX.Catalog
            Dim tbl As New ADOX.Table
            Dim fld As New ADOX.Column
            If CheckPath("C:\Customer\Customer.accdb") Then
                My.Computer.FileSystem.DeleteFile("C:\Customer\Customer.accdb", _
              FileIO.UIOption.AllDialogs, FileIO.RecycleOption.SendToRecycleBin)
            End If
            cat.Create("Provider=Microsoft.ace.OLEDB.12.0;Data Source=C:\Customer\Customer.accdb")

            With tbl
                .Name = "Cliente"
                .ParentCatalog = cat
                .Columns.Append("ID", DataTypeEnum.adInteger)
                .Columns("ID").Properties("AutoIncrement").Value = True
                .Columns("ID").Properties("Nullable").Value = False
                .Columns.Append("FirstName", DataTypeEnum.adVarWChar, 75)
                .Columns("FirstName").Properties("Nullable").Value = True
                .Columns.Append("LastName", DataTypeEnum.adVarWChar, 75)
                .Columns("LastName").Properties("Nullable").Value = True
                .Columns.Append("Age", DataTypeEnum.adInteger)
                .Columns("Age").Properties("Nullable").Value = True
            End With
            cat.Tables.Append(tbl)
            cat = Nothing
            Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub

Recommended Answers

All 2 Replies

Change this line:

cat.Create("Provider=Microsoft.ace.OLEDB.12.0;Data Source=C:\Customer\Customer.accdb")

to this:

cat.Create("Provider=Microsoft.ace.OLEDB.12.0;Data Source=C:\Customer\Customer.accdb:Database Password=<password>")

Thank you for your reply
It worked

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.