Computers & Internet Logo

Related Topics:

Posted on Oct 15, 2008

Create access mdb file by vfp code

Can I get sample codes for creation of access mdb file?
for example ,I want to make a table into a mdb database by code using vfp(visual foxpro).

I wait a happy respond.

My email: [email protected]

  • korea77 Oct 15, 2008

    Can I get sample codes for creation of access mdb file?
    for example ,I want to make a table into a mdb database by code using vfp(visual foxpro).

    I wait a happy respond.

    My email: [email protected]

×

1 Answer

A

Anonymous

Try this

#define dbLogical 1
#define dbNumber 2
#define dbInteger 3
#define dbLongInteger 4
#define dbCurrency 5
#define dbSingle 6
#define dbDouble 7
#define dbDateTime 8
#define dbBinary 9
#define dbText 10
#define dbOLEObject 11
#define dbMemo 12
#define dbReplication 15
#define dbDecimal 16
if file("C:\accesstest.mdb")
delete file c:\accesstest.mdb
endif
public oAccess
oAccess = createobject("Access.application")
oAccess.visible= .t.
newMDB = oAccess.NewCurrentDatabase("C:\accesstest")
newtable = oAccess.CurrentDb.CreateTableDef('testtable')
with newtable
.fields.append(.CreateField("Field1", dbLogical))
.fields.append(.CreateField("Field2", dbNumber))
.fields.append(.CreateField("Field3", dbInteger))
endwith
oAccess.CurrentDb.TableDefs.append( newtable)
dbc2Convert = "\\tpdfiles\data\dfreeman\tip\data\rta\rta"
open database (dbc2convert)

dbgetprop(rta,"table",)

After it runs you will need to close the MDB and reopen it.

Add Your Answer

×

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

1helpful
6answers

Database corrupted

You can use Recovery Toolbox for Access is used for recovering data from corrupted Microsoft Access database files with *.mdb, *.accdb extensions.

For more: https://recoverytoolbox.com/repair_access.html
1helpful
4answers

I need to perform access database repair

The repair method attempts to recover only the tables, indexes and queries in the database. Do not attempt to repair damaged forms, reports, macros and modules. Before executing the Compact and Repair tool, please ensure the following condition:

1. Do not Open Access database must closed
2. Sufficient storage space available - minimum double in size of your Access database on that Disk.
3. Close the .mdb file related to .ldb file before you delete the .ldb file.
4. Then Run the Compact and Repair tool

Read more about Access Repair Toolbox
On:- http://www.access.repairtoolbox.com/

I tried lots of the suggestions and eventually found that this page was the most helpful http://www.filerepairforum.com/forum/microsoft/microsoft-aa/access/1385-%E2%80%8Bhardly-corrupted-access-2007-database
1helpful
6answers

Access database 2003 problem with a copy of database file. How to fix?

You say corrupt, in what way exactly? Do you get any specific error numbers/messages?

Have you tried Access repair program? Compact and Repair. If not, use it. But ensure that you made a backup, it is necessary because all the recovery tips can make the damage even worse.

Also try Jet Compact Utility. This tool created by Microsoft and it is much like Compact and Repair, but more successful in repairing.

If no one of above advice helps, then perhaps you need more powerful solution. In this case try to run a good third-party. I would recommend Recovery Toolbox for Access. It must help you. https://access.recoverytoolbox.com/
1helpful
8answers

MS Access database recovery

Have you tried creating a NEW MDB, and then IMPORTING the objects from the Crashed/Corrupted MDB?

This will SOMETIMES serve to rescue most if not all of the corrupted entities .

Or:
You can try:
eRepair Access is a powerful Access database recovery solution for damaged *.mdb and *.accdb files created in Access 2000 and above. Having such a tool at hand immediately after a database file corruption incident may save you a great deal of time, nerve and, of course, an ample amount of money that would otherwise be paid to third-party recovery services. With eRepair Access, you don't need to depend on anyone and entrust your Access data (often quite sensitive) into somebody else's hands. You don't have to wait. You don't have to call it a day knowing that the damaged Access file will not be restored (if at all) until tomorrow. With eRepair Access, you can be back in the game within minutes!

For more information: http://access.erepairtools.com/

If doesn't help, look here: http://www.filerepairforum.com/forum/microsoft/microsoft-aa/access/933-ms-access-database-recovery
0helpful
1answer

Same as above really

Hi,
I have fixed my problem. I realised that the Microsoft Access Database DSN did not include the *.accdb driver. I deleted the existing DSN and created a new one. This allowed me to select the ODBC driver that worked for both file types.

I cameto realise that I was only having this problem on machines that have been upgraded to excel 2007 and not on machines with full virgin installations. On install both try to create the appropriate DSN but one with the same name already exists on the machines being upgraded and the creation fails.

I hope this helps others.
1helpful
2answers

Convert my database from dpf to mdb

Use access to import external data. It can read dbf and create mdb
0helpful
2answers

Visual foxpro to access

hi
you need to use a ODBC conexion to trasport your tables into table .dbf in fox

or

you need to copy tur tables to excel documents an then import in vfp

bye
0helpful
1answer

Code for find the Ms access database size using visual basic

The way to get the database size is to point to the directory that the database is do a DIR statement with an output to a file as in DIR payroll.mdb>dbsize.txt and then read from the text file, the first field of the second line being the name (which you really don't need) then the size value of the database.

To import the text files using VB 8 use

'Imports System.Data.OleDb Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\path\filename.mdb") Dim cmd As New OleDbCommand("SELECT * INTO [import] FROM [Text;Database=d:\path;Hdr=No].[dbsize.txt]", conn) conn.Open() cmd.ExecuteNonQuery() conn.Close()
0helpful
1answer

About visual basic coding

Hello,
The standard way of creating a database using VBA, which can be modified to suit your needs is this--> Note: the code (wspDefault.CreateDatabase("Newdb.mdb"...), can be altered to save the database in a folder  such as "C:\NEWDB\text.mdb". sub NewDatabase()     Dim wspDefault As Workspace, dbs As Database     Dim tdf As TableDef, fld1 As Field, fld2 As Field     Dim idx As Index, fldIndex As Field     Set wspDefault = DBEngine.Workspaces(0)     ' Create new, encrypted database.     Set dbs = wspDefault.CreateDatabase("Newdb.mdb", _         dbLangGeneral, dbEncrypt)     ' Create new table with two fields.     Set tdf = dbs.CreateTableDef("Contacts")     Set fld1 = tdf.CreateField("ContactID", dbLong)     fld1.Attributes = fld1.Attributes + dbAutoIncrField     Set fld2 = tdf.CreateField("ContactName", dbText, 50)     ' Append fields.     tdf.Fields.Append fld1     tdf.Fields.Append fld2     ' Create primary key index.     Set idx = tdf.CreateIndex("PrimaryKey")     Set fldIndex = idx.CreateField("ContactID", dbLong)     ' Append index fields.     idx.Fields.Append fldIndex     ' Set Primary property.     idx.Primary = True     ' Append index.     tdf.Indexes.Append idx     ' Append TableDef object.     dbs.TableDefs.Append tdf     dbs.TableDefs.Refresh     Set dbs = Nothing End Sub
Hope this helps! Please let me know if you have any questions.Thank You,Raph30
Not finding what you are looking for?

1,175 views

Ask a Question

Usually answered in minutes!

Top Microsoft Computers & Internet Experts

Grand Canyon Tech
Grand Canyon Tech

Level 3 Expert

3867 Answers

k24674

Level 3 Expert

8093 Answers

Brad Brown

Level 3 Expert

19187 Answers

Are you a Microsoft Computer and Internet Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...