473,549 Members | 2,594 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need help: Create Access Database programmaticall y using VB .NET

Hello, i am using ADOX + VB .NET to create a Access Database
programmaticall y. I plan to set some properties of the column such primary
The code is as follows:

Dim cat As ADOX.Catalog
Dim tbl As ADOX.Table
Dim idx As ADOX.Index
Dim prp As ADOX.Property

Set cat = New ADOX.Catalog
cat.ActiveConne ction = CurrentProject. Connection
Set tbl = New ADOX.Table

With tbl
..Name = "tblExperimenta l"
..ParentCatalog = cat
..Columns.Appen d "CustID", adInteger
..Columns("Cust ID").Properties ("Autoincrement ") = True
..Columns("Cust ID").Properties ("Increment" ) = CLng(3)
..Columns("Cust ID").Properties ("Seed") = CLng(2004000)
..Columns.Appen d "Name", adVarWChar, 5
..Columns("Name ").Properties(" Nullable") = True
..Columns.Appen d "Rating", adInteger
..Columns("Rati ng").Properties ("Descriptio n") = "Customer Rating"
..Columns("Rati ng").Properties ("Jet OLEDB:Column Validation Text") = "Must be
between 1 and 10"
..Columns("Rati ng").Properties ("Jet OLEDB:Column Validation Rule") = ">0 and
..Columns("Rati ng").Properties ("Default") = 5
End With

cat.Tables.Appe nd tbl

Set idx = New ADOX.Index

With idx
..Name = "PrimaryKey "
..Columns.Appen d "CustID"
..PrimaryKey = True
..Unique = True
End With

tbl.Indexes.App end idx

Set idx = Nothing
Set cat = Nothing
when I run the program, it always issue some error: type is invalid.

Can anyone tell me how should I correct my code?
Nov 21 '05 #1
1 3423

Because ADOX has in connection with VBNet a low use, there is probably a
better newsgroup for your question

microsoft.publi c.data.ado

It has a medium/low activity however I have seen that almost every question
get an answer.

There are people active in that newsgroup who know VBNET.

I hope this helps anyway

Nov 21 '05 #2

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

Similar topics

by: swingingming | last post by:
Hi, for 5 weeks, I finished my mdb project. Thanks to all you guys. Now, I would like to put it on a server then 5-6 people can share it. I heard about the splitting back-end database, put it on a file server or DB server. Then install the front-end on every client machine. And clients must be able to connect to the backend remotely. Should I...
by: Jacob | last post by:
Happy New Year! I'm writing a program that will need to store large amounts of data from several DataSets that I create at runtime (for information like email, calendar, etc...). The trick is that these files will need to be created programmatically. I think saving the DataSets into Access .mdb files is a logical choice, but I'm unable to...
by: R Reyes | last post by:
Just wondering if anyone knows the pros/cons between creating a database programmatically vs using the application's tool windows/features that come with SQLServer, Access, Oracle, etc... Is it the same? Does it really matter? I have created databases with .NET programmatically and it works fine, but why would anyone want to do all this...
by: DM | last post by:
newbie trying to set up a Database and keep getting the same result. ERROR An error occured while retrieving the information from the database: Unable to cast COM object of type 'System._ComObject' to interface type 'Microsoft.VisualStudio.OLE.Interop.IServiceProvider'. This operation failed because the QueryInterface call on th COM...
by: peshekeedweller | last post by:
Using asp.net 1.1. vb.net 2003. I am trying to connect to a remote sql server 2000 on a virtual machine running windows 2000 server. I can connect through the server explorer in visual studio, but cannot connect through code. I have done it before and can not do it now; I don't know what changed. (I also cannot connect to local Access...
by: Cheryl Langdon | last post by:
Hello everyone, This is my first attempt at getting help in this manner. Please forgive me if this is an inappropriate request. I suddenly find myself in urgent need of instruction on how to communicate with a MySQL database table on a web server, from inside of my company's Access-VBA application. I know VBA pretty well but have never...
by: Siva | last post by:
Hi, In my ASP.Net 2.0 app, I have a gridview whose data is being populated using an object data source which retrieves data from a data access layer. The Select method returns a static list of orders. The order contains a bunch of data retrieved from SQL server. I do display only a part of them in my Gridview by using <asp:BoundField. I do...
by: Alan Mailer | last post by:
A project I'm working on is going to use VB6 as a front end. The back end is going to be pre-existing MS Access 2002 database tables which already have records in them *but do not have any AutoNumber* fields in them. Correct me if I'm wrong, but I'm assuming this means that I cannot now alter these existing Access tables and change their...
by: AAaron123 | last post by:
I want to create a database with one table on the host. I can't user SQL Server Management Studio to do it so I guess I have to do it programmatically. I have in mind that in the session start (or maybe application start would be better) I'd check to see it the database exists and if not create it. The problem is that I have no idea how...
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.