Please see the pic. I am attaching DBs using following code.
Dim conn As New SqlConnection("Server=MyHomeServer\SQLExpress;Database=master;Integrated Security=SSPI")
Dim cmd As New SqlCommand("", conn)
cmd.CommandText = "CREATE DATABASE dbNoPWD ON ( FILENAME = 'd:\dbNoPWD.mdf' ), ( FILENAME = 'd:\dbNoPWD_log.ldf' ) FOR ATTACH"
conn.Open()
cmd.ExecuteNonQuery()
cmd.Dispose()
conn.Dispose()
Please note I donot want to give any username and password.
When I ran the above code and then checked SSMS, I found my attach DB was not checked in Roles (pls. see pic.)

The problem with this is my network computers can not access this DB. I want to run some code like above (without sa password) and want that all my network computers can access the DB without my user get involved in setting up SSMS.
In your connection string when creating the database you’re using windows authentication. Therefore if your ActiveDirector account is JOE then the owner of the dbNoPWD database will be JOE, not SA. That’s why your screenshot shows SA with no mapping to the dbNoPWD.
But here’s your problem: SA’s mappings have nothing to do with whether or not other SqlServer logins will be able to access your database (unless they belong to the sysadmin server role). Each SQLServer login must have it’s own mapping to your new database or else they won’t be able to use it.
So, let’s solve your problem. If you want people to have read/write access to your new database add some TSQL after your database creation statements to map users to your new database. Something like this:
If you have a lot of users an easier way it to create logins for entire windows groups and then just assign mapping for the entire group to your database.