Access mdb file with vb 
Author Message
 Access mdb file with vb

How is is possible to create an access mdb file with vb and not with
microsoft access of office?

is it possible at all?

*** Sent via Developersdex http://www.*-*-*.com/ ***
Don't just participate in USENET...get rewarded for it!



Sun, 24 Oct 2004 04:25:01 GMT  
 Access mdb file with vb



How is is possible to create an access mdb file with vb and not with
microsoft access of office?

is it possible at all?

You can use ADOX (Microsoft ADO Ext 2.x for DDL and Security):

Sub CreateAccessWithADOX()

Dim tbl As New ADOX.Table
Dim col As New ADOX.Column
Dim cat As New ADOX.Catalog

'Engine Type=4 is Access 97 and a value of 5 is Access 2000
cat.Create "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                     "Data Source=d:\My Documents\db1.mdb;" & _
                     "Jet OLEDB:Engine Type=4;"

tbl.NAME = "NewTable"
col.NAME = "DateField"
col.Type = adDate
tbl.Columns.Append col
Set col = New ADOX.Column
col.NAME = "Address2"
col.Type = adVarWChar
col.DefinedSize = 20
col.Attributes = adColNullable
tbl.Columns.Append col
Set col = New ADOX.Column
col.NAME = "Age"
col.Type = adInteger
col.Attributes = adColNullable
tbl.Columns.Append col
cat.Tables.Append tbl

tbl.Columns("Address2").Properties("Jet OLEDB:Allow Zero Length").Value = True

Set cat = Nothing

End Sub


Microsoft MVP (Visual Basic)



Sun, 24 Oct 2004 21:56:08 GMT  
 Access mdb file with vb
Something I do is put the mdb in my prog as a binary resource, then save
this to disk when a user wants a new file. This way, I don't have to do all
that CREATE TABLE stuff.

Just a thought.

Tim H


Quote:


>
>
> How is is possible to create an access mdb file with vb and not with
> microsoft access of office?
>
> is it possible at all?

> You can use ADOX (Microsoft ADO Ext 2.x for DDL and Security):

> Sub CreateAccessWithADOX()

> Dim tbl As New ADOX.Table
> Dim col As New ADOX.Column
> Dim cat As New ADOX.Catalog

> 'Engine Type=4 is Access 97 and a value of 5 is Access 2000
> cat.Create "Provider=Microsoft.Jet.OLEDB.4.0;" & _
>                      "Data Source=d:\My Documents\db1.mdb;" & _
>                      "Jet OLEDB:Engine Type=4;"

> tbl.NAME = "NewTable"
> col.NAME = "DateField"
> col.Type = adDate
> tbl.Columns.Append col
> Set col = New ADOX.Column
> col.NAME = "Address2"
> col.Type = adVarWChar
> col.DefinedSize = 20
> col.Attributes = adColNullable
> tbl.Columns.Append col
> Set col = New ADOX.Column
> col.NAME = "Age"
> col.Type = adInteger
> col.Attributes = adColNullable
> tbl.Columns.Append col
> cat.Tables.Append tbl

> tbl.Columns("Address2").Properties("Jet OLEDB:Allow Zero Length").Value =
True

> Set cat = Nothing

> End Sub


> Microsoft MVP (Visual Basic)



Sun, 24 Oct 2004 23:56:19 GMT  
 Access mdb file with vb

Paul, thanx.
i added the reference, but it gets stuck on this line:

cat.Create "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                     "Data Source=d:\My Documents\db1.mdb;" & _
                     "Jet OLEDB:Engine Type=4;"

:-(

about the binary file, the mdb is a binary file actualy, do you mean
that you use an empty file and each time refills it with data and use
another copy to paste on the HD, or does the program holds it somehow
(maby as a string, contaning 0011001...) and then you save it as it is?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

  _alt.0
1K Download


Mon, 25 Oct 2004 16:19:41 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Using VB to access MS Access (mdb file) in remote host

2. Does user need Microsoft Access License to use EXE file that access .MDB file

3. how to launch an Access Application (mdb file) from VB.Net

4. Q: How2 encrypt mdb files accessed by VB apps

5. Other easier simpler ways to access a mdb file from VB

6. Using an mdb file with VB 6 ADO without Access installed

7. Opening an .mdb file from VB into Access

8. Opening an .mdb file from VB into Access

9. TransferDatabase method from Access 95 mdb to Access 97 mdb

10. Access Object Browser shows refernce to access mdb file

11. Linking Access Tables in Different *.mdb Files, Populating an Access Table From Several Others

12. accessing remote Access MDB file

 

 
Powered by phpBB® Forum Software