Hello Sir,
How to assign more than one primary key to table by this below following
code. i am able assign to a single field only. how to assign primary key to
more than one field. the primary key assigning code line is symboled kept
with in the *************** in the below code.
'Creating database
Dim cat As Catalog = New Catalog
cat.Create("Pro vider=Microsoft .Jet.OLEDB.4.0; " & _
"Data Source= " & Application.Sta rtupPath & "\databases " & "\" & fname1 &
";" & "Jet OLEDB:Engine Type=5")
cat = Nothing
MsgBox("Databas e succesfully created")
End If
'creating tables in the database
'
' This code adds a single-field Primary key
'
Dim Cn As ADODB.Connectio n
Dim Cat2 As ADOX.Catalog
Dim objTable1, objtable2 As ADOX.Table
Cn = New ADODB.Connectio n
Cat2 = New ADOX.Catalog
objTable1 = New ADOX.Table
objtable2 = New ADOX.Table
'Open the connection
Try
Cn.Open("Provid er=Microsoft.Je t.OLEDB.4.0;" & _
"Data Source= " & Application.Sta rtupPath & "\databases " & "\" & fname1 &
";" & "Jet OLEDB:Engine Type=5")
'"Provider=Micr osoft.Jet.OLEDB .4.0;Data Source=d:\sampl e\gaffar.mdb"
Catch ex As Exception
MsgBox(ex.Messa ge)
End Try
'Open the Catalog
Cat2.ActiveConn ection = Cn
'Create the table
objTable1.Name = "Test_Table "
objtable2.Name = "Test_Table 2"
'Create and Append a new field to the "Test_Table " Columns Collection
objTable1.Colum ns.Append("comp any", DataTypeEnum.ad VarWChar)
objTable1.Colum ns.Append("cont act", DataTypeEnum.ad VarWChar)
'Create and Append a new key. Note that we are merely passing
'the "PimaryKey_Fiel d" column as the source of the primary key. This
'new Key will be Appended to the Keys Collection of "Test_Table "
'dsclient.Table s(0).PrimaryKey = New DataColumn
'{dsClient.Tabl es(0).Columns(" FirstName"),
'dsClient.Table s(0).Columns("L astName")}
*************** *************** *************** *************** *************** *
*************** **
objTable1.Keys. Append("Primary Key", KeyTypeEnum.adK eyPrimary, "company")
*************** *************** *************** *************** *************** *
*************** **
'Append the newly created table to the Tables Collection
Try
Cat2.Tables.App end(objTable1)
Catch ex As Exception
MsgBox(ex.Messa ge)
End Try
Cat2.Tables.App end(objtable2)
' clean up objects
' objKey = Nothing
objTable1 = Nothing
objtable2 = Nothing
Cat2 = Nothing 2 1412 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Mavis Tilden |
last post by:
Hi all,
So I've been reading the newsgroups, and reading a few books trying to learn
SQL and SQL Server 2000. The books tell me I need a Primary Key, and that
every table should have one. I know (I think) that a Primary Key is a
special field that uniquely identifies each record or row within a table.
My question is this: If I have a field or column whose values are all (and
will be) different in every row, is that what a Primary Key...
|
by: gaffar |
last post by:
Hello Sir,
How to assign more than one primary key to table by this below following
code. i am able assign to a single field only. how to assign primary key to
more than one field. the primary key assigning code line is symboled kept
with in the *************** in the below code.
'Creating database
Dim cat As Catalog = New Catalog
|
by: Megan |
last post by:
Hi everybody-
I have 2 tables, Hearings and Rulings. Both have primary keys called,
CaseID, that are autonumbers. I don't want both tables to have the
same autonumber. For example, if Hearings has 55, then I want Rulings
to have a number greater than 55. Two or more Hearings may be entered
before a Ruling is entered. For example, Hearings with CaseIDs= 55,
56, and 57 may be entered before a Ruling or vice versa. There is no
definite...
|
by: gaffar |
last post by:
Hello Sir,
How to assign more than one primary key to table by this below following
code. i am able assign to a single field only. how to assign primary key to
more than one field. the primary key assigning code line is symboled kept
with in the *************** in the below code.
'Creating database
Dim cat As Catalog = New Catalog
|
by: dBNovice |
last post by:
Hi all! I have 3 separate forms: Tasks, Subtasks, and Elements. All 3
is related by TaskId and Subtasks and Elements are related by
SubtaskID. In the DB after I add a task, I want to be able to add one
or more subtasks and then one or more elements. I need the subtasks
and elements to be have the same taskid as the task; also I want the
element to have the same subtaskId as the subtask. I have been able to
design the system to include...
| |
by: Paul Hunter |
last post by:
I am new to databases and thus to Access. I have a situation where I am
trying to figure out how to key some tables I am working with. Consider that
I have a database of my own records which are invoices I work on. These
invoices are from four companies with their own invoice numbers. So, I
cannot key by invoice number because there is a likelihood of invoice
numbers duplicated by different companies. The records in this table of
joined...
|
by: sonal |
last post by:
Hi all,
I hv started with python just recently... and have been assigned to
make an utility which would be used for data validations...
In short we take up various comma separated data files
for eg: area.txt, school.txt, students.txt.... and so on (ok?!?)
now,
1. area code used in the school.txt must be defined in the area.txt
(Primary key in area => area_code defined in area.txt
& Foreign key on school => area_code defined in...
|
by: LurfysMa |
last post by:
Most of the reference books recommend autonum primary keys, but the
Access help says that any unique keys will work.
What are the tradeoffs?
I have several tables that have unique fields. Can I use them as
primary keys or should I define an autonum primary key?
One table has information about the 50 states in the US. The table
looks like this:
|
by: mark_aok |
last post by:
Hi all,
I have a situation where I need to determine a specific table's
primary key, and then output it.
I have tried the Database Object, and the Record Object, but I've had
no luck.
Ideally there would be something like,
|
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
| |
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 most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |