Sir,
How to establish relationship between the tables in my vb.net
application.
very urgent sir,
Thanking you sir.
here is the code for creating database and tables. How to establish
relationship between the tables in my vb.net application.
'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, objtable3, objtable4 As ADOX.Table
Dim objkey1 As ADOX.Key
Cn = New ADODB.Connectio n
Cat2 = New ADOX.Catalog
objTable1 = New ADOX.Table
objtable2 = New ADOX.Table
objtable3 = New ADOX.Table
objtable4 = New ADOX.Table
objkey1 = New ADOX.Key
'Open the connection
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"
'Open the Catalog
Cat2.ActiveConn ection = Cn
'Create the table
objTable1.Name = "new_custdetail s"
objtable2.Name = "contact_no te"
objtable3.Name = "contact_saleso pportunity"
objtable4.Name = "contact_activi ties"
'Create and Append a new field to the "new_custdetail s"
Columns Collection
objTable1.Colum ns.Append("comp any", DataTypeEnum.ad VarWChar)
objTable1.Colum ns.Append("cont act", DataTypeEnum.ad VarWChar)
objTable1.Colum ns.Append("salu tation",
DataTypeEnum.ad VarWChar)
objTable1.Colum ns.Append("titl e", DataTypeEnum.ad VarWChar)
objTable1.Colum ns.Append("dept ", DataTypeEnum.ad VarWChar)
objTable1.Colum ns.Append("phon e", DataTypeEnum.ad Integer)
objTable1.Colum ns.Append("phex t1", DataTypeEnum.ad Integer)
objTable1.Colum ns.Append("rec_ creator",
DataTypeEnum.ad VarWChar)
objTable1.Colum ns.Append("rec_ mgr", DataTypeEnum.ad VarWChar)
'Append the newly created table to the Tables
Collection
objkey1.Name = "PrimaryKey "
objkey1.Type = KeyTypeEnum.adK eyPrimary
objkey1.Columns .Append("compan y")
objkey1.Columns .Append("contac t")
objkey1.Columns .Append("dept")
Cat2.Tables.App end(objTable1)
Cat2.Tables.App end(objtable2)
Cat2.Tables.App end(objtable3)
Cat2.Tables.App end(objtable4)
' clean up objects
' objKey = Nothing
objTable1 = Nothing
objtable2 = Nothing
objtable3 = Nothing
objtable4 = Nothing
Cat2 = Nothing
Cn.Close()
Cn = Nothing
*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!