I'm not sure how you'd do it from scratch. What I do is include a blank database file as a resource with a specific password. Then, I just write that blank database to the file location and alter the database password. My code looks like:
Public Function CreateDatabase(ByVal Path As String) As String
Dim password As String = ""
Dim newPasswordEntry As New PasswordEntry()
If newPasswordEntry.result = Windows.Forms.DialogResult.OK Then
password = newPasswordEntry.value
Catch ex As Exception
Dim cn As New OleDbConnection
cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Path & _
";Jet OLEDB:Database Password=password;" & _
"Mode=Share Deny Read|Share Deny Write;"
Dim cmd As New OleDbCommand
cmd.Connection = cn
cmd.CommandText = "ALTER DATABASE PASSWORD [" & password & "][password]"
Of course, that's VB, so you'd have to change a bit (especially the accessing the file in the resources), but that's the idea.