473,836 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

please solve the problem

Sir,

I am developing an application in vb.net and the backend database is
ms-access my problem is i want delete one record from master table, that
deleted record automatically deleted from child table. how this problem is
solved any one knows please give me source code.

It is very urgent.
Thnking you sir,
Nov 21 '05 #1
3 1255

"gaffar" <sa********@yah oo.co.in> wrote in message
news:uM******** ******@TK2MSFTN GP09.phx.gbl...
Sir,

I am developing an application in vb.net and the backend database is
ms-access my problem is i want delete one record from master table, that
deleted record automatically deleted from child table. how this problem is
solved any one knows please give me source code.

It is very urgent.
Thnking you sir,

If you want cascading deletes automatically, specify that property in the
relationship between the tables in question in your database. No code is
needed in your application.

--
Peter [MVP Visual Developer]
Jack of all trades, master of none.
Nov 21 '05 #2
"gaffar" <sa********@yah oo.co.in> wrote in message
news:uM******** ******@TK2MSFTN GP09.phx.gbl...
I am developing an application in vb.net and the backend database
is ms-access my problem is i want delete one record from master
table, that deleted record automatically deleted from child table.


This is known as a Cascading Delete and is handled by the
relationships between your database tables. If you use Cascading
Deletes, you only need to delete from the Master Table; no code
is required to deal with the Child table; the database takes care of
it all for you. However ...

I would use Cascading Deletes with caution. All too often, Users
will delete things that they didn't /mean/ to (no matter how many
"Are you sure?" dialogs you put in front of them) and, by cascading
the deletion, you can obliterate of an /awful/ lot of records.

It /might/ be better to use the table relationships to /prevent/ deletion
of a Master record where any Child records exist and, in your code,
delete from the Child table, then from the Master table.

HTH,
Phill W.
Nov 21 '05 #3

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!
Nov 21 '05 #4

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

Similar topics

28
3311
by: stu_gots | last post by:
I have been losing sleep over this puzzle, and I'm convinced my train of thought is heading in the wrong direction. It is difficult to explain my circumstances, so I will present an identical make-believe challenge in order to avoid confusing the issue further. Suppose I was hosting a dinner and I wanted to invite exactly 12 guests from my neighborhood. I'm really picky about that... I have 12 chairs besides my own, and I want them all...
23
3301
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application to create certain textboxes, labels, and combo boxes? Any ideas would be appreciated. Thanks
7
1662
by: Mat | last post by:
I am developping multi-user windows application. i use Access database. user edit, add and delete data from database. Request: when an item is deleted ,added or modified by an user, all others user in the network which has application running should automatically see the change. in case of remove action, the item should disappear from the listview.
5
2244
by: CoreyWhite | last post by:
It is possible to use martingale probability theory to beat some games of chance. In a fair game of coin toss, where the odds reach an equilibrium of 50/50 chain reactions do occur. This can be explained using martingale probability theory, but in simpler terms it only shows an example of how order emerges out of chaos. Example: One player has 3 pennies, and another player has only 1 penny. A fair coin is tossed every round to determine...
5
2586
by: settyv | last post by:
Hi, Below is the Javascript function that am trying to call from asp:Button control. <script language="javascript"> function ValidateDate(fromDate,toDate) { var fromDate=new Date();
1
1709
by: shapper | last post by:
Hello, For the past hours I have been trying to solve a problem which is driving me crazy. I have to different codes where the problem to solve is the same: CODE 1 (Transforms a XML document using a XSL file): Function Trans()
1
2107
by: rocksoft | last post by:
Hi, I am working in asp.net with C# web application, i have used one textbox and image button for search funtion, i have created one user control for this, but after i have entered value in textbox, i have pressed the button, its not at all working, if i will use mouse i can able to search values, how to enable to enter key at keydown event of textbox, the following script i have used ,
14
3471
by: rashmidutt | last post by:
hello sir i am making project on vb.net language..and project is on hospital management..its major project..and too many fields are present in its data base..i was connecting data base in forms but there is coming error..SIR PLEASE SORT OUT ERROR FROM MY COADING..what can i do to solve this error please give me sugession or if you can send me coading for adding information from form.than i will be thankfull to u..i have written all fields which...
2
2380
by: itsvineeth209 | last post by:
My task is to create login control without using login control in tools. I shouldnt use sqldatasource or any other. I should use only data sets, data adapters and data readers etc. U had created table login with fields username(varchar(50)), password(varchar(50)), firstname(varchar(50)), lastname(varchar(50)). U had to display username , first name, last name in default.aspx page after login. One more condition is that, if user fails login...
6
2198
by: shapper | last post by:
Hello, I am creating a form that includes a few JQuery scripts and TinyMCE Editor: http://www.27lamps.com/Beta/Form/Form.html I am having a few problems with my CSS: 1. Restyling the Select
0
9810
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9654
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,...
0
10818
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10526
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 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...
1
7770
isladogs
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5641
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...
0
5809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4436
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
3
3094
bsmnconsultancy
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...

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.