473,385 Members | 1,597 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Creating MS Access database

Hi there,

I'm currently trying to create a MS access file at runtime, but I stumble
into some problems.
1. When I use Datatype adUnsignedInt I get an error (invalid type).
2. Which datatype must I use to create an autonumbering field?
3. Which datatype must I use to create an OLE-object field?

I'm currently using Microsoft ActiveX Data Objects Library 2.8 and using
engine type 5.

Can anybody help me out here?

thnx
Nov 19 '06 #1
10 2921
On Sun, 19 Nov 2006 16:09:53 +0100, "C# Beginner" <de********@orange.nlwrote:
>Hi there,

I'm currently trying to create a MS access file at runtime, but I stumble
into some problems.
1. When I use Datatype adUnsignedInt I get an error (invalid type).
2. Which datatype must I use to create an autonumbering field?
3. Which datatype must I use to create an OLE-object field?

I'm currently using Microsoft ActiveX Data Objects Library 2.8 and using
engine type 5.

Can anybody help me out here?

thnx
Is the database you are trying to create always the same(schema-wise)? If it is
why not just distribute an empty DB with all the tables, etc. already created
and copy it when you want to create a new one?

Additionally, DAO is still a viable option for doing this. To use it just add
the dll to your project.

Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
Nov 19 '06 #2
Hi Otis,

Thanks for the rapid respons.

I'm currently rewriting a program which I developed in VB6 using DAO, in
which users were able to create
their own databases at demand (no schema). I like to keep it that way.

My problem is that DataTypeEnum contains a lot of types of which some can't
be used (so it seems). So I need to understand if and how each type works.
OLE-object type and Autonumber are examples of types which aren't available
in DatatTypeEnum, so I must find an alternative type for them.

There are a lot of examples how the create a access database at runtime, but
I still can't find the solution for my problem. Most examples aren't writing
c# anyway.

thnx

DD
"Otis Mukinfus" <ph***@emailaddress.comschreef in bericht
news:c0********************************@4ax.com...
On Sun, 19 Nov 2006 16:09:53 +0100, "C# Beginner" <de********@orange.nl>
wrote:
>>Hi there,

I'm currently trying to create a MS access file at runtime, but I stumble
into some problems.
1. When I use Datatype adUnsignedInt I get an error (invalid type).
2. Which datatype must I use to create an autonumbering field?
3. Which datatype must I use to create an OLE-object field?

I'm currently using Microsoft ActiveX Data Objects Library 2.8 and using
engine type 5.

Can anybody help me out here?

thnx

Is the database you are trying to create always the same(schema-wise)? If
it is
why not just distribute an empty DB with all the tables, etc. already
created
and copy it when you want to create a new one?

Additionally, DAO is still a viable option for doing this. To use it just
add
the dll to your project.

Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com

Nov 19 '06 #3
"C# Beginner" <de********@orange.nlwrote in message
news:45***********************@news.wanadoo.nl...
There are a lot of examples how the create a access database at runtime,
but I still can't find the solution for my problem. Most examples aren't
writing c# anyway.
Did you actually read Otis' reply?

How many different versions of this Access (by which, of course, you mean
Jet) database do you need to create...?
Nov 19 '06 #4
Hi Mark,

Sorry, it seems that my english is a little bit poor, but I thought I
mentioned that the creation of databases depends on the users wishes at
runtime (have you actually read my mail?).

Though I thank Otis for his rapid respons and suggestion, his solution will
not do for my project.

The usage of DAO can be a solution, but I rather try it with .NET elements
(ADO/ADOX), since DAO is (officialy) not supported in .NET.

Back to my project. Think of it like VisData which was included in Visual
Studio 6.

DD
"Mark Rae" <ma**@markNOSPAMrae.comschreef in bericht
news:el**************@TK2MSFTNGP06.phx.gbl...
"C# Beginner" <de********@orange.nlwrote in message
news:45***********************@news.wanadoo.nl...
>There are a lot of examples how the create a access database at runtime,
but I still can't find the solution for my problem. Most examples aren't
writing c# anyway.

Did you actually read Otis' reply?

How many different versions of this Access (by which, of course, you mean
Jet) database do you need to create...?

Nov 20 '06 #5
"C# Beginner" <de********@orange.nlwrote in message
news:45***********************@news.wanadoo.nl...
but I thought I mentioned that the creation of databases depends on the
users wishes at runtime
You didn't - you said "I'm currently trying to create a MS access file at
runtime" and then mentioned some of the DDL issues you were facing - no
mention that the database needs to be different for each user...
(have you actually read my mail?).
Yes.
The usage of DAO can be a solution, but I rather try it with .NET elements
(ADO/ADOX), since DAO is (officialy) not supported in .NET.
ADOX is probably your best choice, even though it is not officially
supported in .NET either...
http://support.microsoft.com/kb/317881
http://www.google.co.uk/search?sourc...&q=%2eNET+ADOX
Nov 20 '06 #6
Hi Mark,

Sorry I wasn't specific in my first mail, but I thought my response to Otis
was clear enough.

Maybe I was or maybe I wasn't.... no need to argue here. Next time I try to
choose my words more carefully and be more specific. (Though it's no easy
when trying to communicate in a language that is my native language, but I'm
still learning).

Enough said.


For anybody who's interested....

http://www.codeguru.com/cpp/data/mfc...cle.php/c4343/

Now I only have to figure out how to translate
'col.Properties["AutoIncrement"] = true'. It does work in VB, but it seems
that the Properties collection is readonly in C#.

thnx for the interesting links Mark

DD

"Mark Rae" <ma**@markNOSPAMrae.comschreef in bericht
news:uI**************@TK2MSFTNGP04.phx.gbl...
"C# Beginner" <de********@orange.nlwrote in message
news:45***********************@news.wanadoo.nl...
>but I thought I mentioned that the creation of databases depends on the
users wishes at runtime

You didn't - you said "I'm currently trying to create a MS access file at
runtime" and then mentioned some of the DDL issues you were facing - no
mention that the database needs to be different for each user...
>(have you actually read my mail?).

Yes.
>The usage of DAO can be a solution, but I rather try it with .NET
elements (ADO/ADOX), since DAO is (officialy) not supported in .NET.

ADOX is probably your best choice, even though it is not officially
supported in .NET either...
http://support.microsoft.com/kb/317881
http://www.google.co.uk/search?sourc...&q=%2eNET+ADOX

Nov 20 '06 #7
On Mon, 20 Nov 2006 07:58:49 +0100, "C# Beginner" <de********@orange.nlwrote:
>Hi Mark,

Sorry, it seems that my english is a little bit poor, but I thought I
mentioned that the creation of databases depends on the users wishes at
runtime (have you actually read my mail?).

Though I thank Otis for his rapid respons and suggestion, his solution will
not do for my project.

The usage of DAO can be a solution, but I rather try it with .NET elements
(ADO/ADOX), since DAO is (officialy) not supported in .NET.
[snip]

C# Beginner,

Your original post said absolutely nothing about users creating their own
tables, etc. Have you bothered to go back and read your original post? Don't
be trying to get a splinter out of mine and Mark's eyes without first taking off
the blindfold you are wearing.

ADOX is not an element of the .NET framework. That is why you will not see it
listed if you type "ADOX" into the Visual Studio Help Index, but you WILL find
"DAO" if you type it in. Which do YOU think MS would rather you use????.

If you want an entirely .NET solution, then I suggest you ditch the Jet database
technology and use SQL server 2005 Express (free) or the new SQL Server Compact
Edition (not very well supported yet, but also free).

There is no reason you cannot have an empty Jet database for distribution and
then USE DDL to create the tables, etc for the user. Write the DDL script and
execute it with the ExecuteNonQuery method of the OLEDB provider. Copying the
Jet DB file is about three or four lines of code and I'm sure you know how to
write the DDL.
Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com
Nov 20 '06 #8
"Otis Mukinfus" <ph***@emailaddress.comwrote in message
news:l6********************************@4ax.com...
ADOX is not an element of the .NET framework. That is why you will not
see it
listed if you type "ADOX" into the Visual Studio Help Index, but you WILL
find
"DAO" if you type it in.
Indeed.
If you want an entirely .NET solution, then I suggest you ditch the Jet
database
technology and use SQL server 2005 Express (free) or the new SQL Server
Compact
Edition (not very well supported yet, but also free).
In fact, Access 2007 does not even use the old Jet database format by
default: http://office.microsoft.com/en-us/ac...678311033.aspx
though, obviously, it *can* still work with the previous version...
There is no reason you cannot have an empty Jet database for distribution
and
then USE DDL to create the tables, etc for the user. Write the DDL script
and
execute it with the ExecuteNonQuery method of the OLEDB provider. Copying
the
Jet DB file is about three or four lines of code and I'm sure you know how
to
write the DDL.
Actually, that is probably the best solution - no need for ADO, ADOX or DAO
at all...
Nov 20 '06 #9
Sorry for the confusion. It is correct I said nothing about users creating
their own databases in my first question. I mentioned it only later in my
first response to your first suggestion. I should have made that clearer in
my response to Mark. Sorry Mark.

Though I almost have the answer to my problem, you suggestion of using an
empty database and use later on the DDL to add more tables as wished by
other users, never crossed my mind. I was fixed on using only one method
(ADOX or DAO) and never thought of combining two methods (ADOX and DDL).

thnx for the tip.

DD
"Otis Mukinfus" <ph***@emailaddress.comschreef in bericht
news:l6********************************@4ax.com...
On Mon, 20 Nov 2006 07:58:49 +0100, "C# Beginner" <de********@orange.nl>
wrote:
>>Hi Mark,

Sorry, it seems that my english is a little bit poor, but I thought I
mentioned that the creation of databases depends on the users wishes at
runtime (have you actually read my mail?).

Though I thank Otis for his rapid respons and suggestion, his solution
will
not do for my project.

The usage of DAO can be a solution, but I rather try it with .NET elements
(ADO/ADOX), since DAO is (officialy) not supported in .NET.
[snip]

C# Beginner,

Your original post said absolutely nothing about users creating their own
tables, etc. Have you bothered to go back and read your original post?
Don't
be trying to get a splinter out of mine and Mark's eyes without first
taking off
the blindfold you are wearing.

ADOX is not an element of the .NET framework. That is why you will not
see it
listed if you type "ADOX" into the Visual Studio Help Index, but you WILL
find
"DAO" if you type it in. Which do YOU think MS would rather you use????.

If you want an entirely .NET solution, then I suggest you ditch the Jet
database
technology and use SQL server 2005 Express (free) or the new SQL Server
Compact
Edition (not very well supported yet, but also free).

There is no reason you cannot have an empty Jet database for distribution
and
then USE DDL to create the tables, etc for the user. Write the DDL script
and
execute it with the ExecuteNonQuery method of the OLEDB provider. Copying
the
Jet DB file is about three or four lines of code and I'm sure you know how
to
write the DDL.
Good luck with your project,

Otis Mukinfus
http://www.arltex.com
http://www.tomchilders.com

Nov 20 '06 #10
"C# Beginner" <de********@orange.nlwrote in message
news:45***********************@news.wanadoo.nl...
Though I almost have the answer to my problem, you suggestion of using an
empty database and use later on the DDL to add more tables as wished by
other users, never crossed my mind. I was fixed on using only one method
(ADOX or DAO) and never thought of combining two methods (ADOX and DDL).
No need for ADOX - that's the whole point...

1) Using Access (or whatever) create a totally blank database.

2) Add the totally blank database to your project as an embedded resource.

3) When you need to create a new database, extract the database from your
project and save it somewhere for the user

4) Add the various object to it as required by passing DDL SQL to the
ExecuteQuery method
Nov 20 '06 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Dim St Thomas | last post by:
I am a developer working on a database client program. I am testing this program on a Windows XP machine (1.5 GHz AMD chip, 480 Mb RAM, 60 Gb disk) This machine has Oracle 9.2.0.1.0 and RedBrick...
4
by: Tony | last post by:
G'day My attempt to create an MDE file was unsuccessful. The attempt produced an error that effectively said the (MDB) file was to big. The MDB consists of about 30 tables, 50 forms and 3...
7
by: John Baker | last post by:
Hi: I would like to know how to create a temp DB to store the data in a table while I do something else with the table. Specifically, how do I create the temp remove the temp I want to be...
6
by: Jerry Spence1 | last post by:
Why doesn't the following work in my ASP program? I have imported ADOX I am trying to create a temporary database on the user's PC. The example is taken from Microsoft. Dim cat As Catalog =...
2
by: John Dann | last post by:
Apologies if this isn't the best group - maybe someone can suggest a more appropriate one - I can't immediately see anything on ado.net. I need to store a significant amount of data (say 1-10MB)...
9
by: dennist685 | last post by:
Walkthrough: Creating a Web Page to Display Access Database Data I've started the above walkthrough. However, near the beginning it gives the following instructions To set permissions in the...
1
by: dave | last post by:
Hello: In Visual Studio 6.0 there is "VisData" to create Access database files. (file.MDB". Q: Does Visual Studio 2005 have tool(s) that create Access database files (file.MDB) ? thank...
4
by: RSH | last post by:
Hi, I have a situation where I have created a little application that makes an Access database from a SQL Database for reporting purposes. it does the job well, but it seems a bit slow. Is...
2
by: Andy | last post by:
Hi guys I having a problem creating a report in Access 2003 project talking to a SQL database through and ODBC connect. After hours of trying things from Access Help, MSDN and Google I still...
1
by: sainiamit25 | last post by:
Hi, I want to create a materlised view log in my database A and materlised view in some other database B. I was successful in creating materlised view in database B (after creating a dblink with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.