Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 18th, 2006, 02:09 AM
Registered User
Join Date: Nov 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default delete a composite key record

im new to asp.net n databases...
i have got two tables in my database. these are:-
now i want to insert a record in training_details and delete that same record wd less fiels from training_details...
i have 8 fields in training_details and 4 in pendingtraining_details.
the fields in pendingtraining_details are:-
all these fiels are composite keys of this table and same fields are composite keys of trainig_details...

the code that i have tried for performing this operation is...
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim con As OleDbConnection
        Dim str1 As String
        Dim str2 As String
        Dim com1 As OleDbCommand
        Dim com2 As OleDbCommand
        con = New OleDbConnection("PROVIDER=Microsoft.Jet.OLEDB.4.0; DATA Source=C:\Documents and Settings\nitpu.ITPVIS19\My Documents\training_project.mdb")
        str1 = "insert into training_details(name_org,training_type,course,req uest_date,start_date,end_date,trainees,incharge_na me) values(@name_org,@training_type,@course,@request_d ate,@start_date,@end_date,@trainees,@incharge_name )"

        str2 = "delete from pendingtraining_details where name_org=@name_org & training_type=@training_type & course=@course & request_date=@request_date"

        com1 = New OleDbCommand(str1, con)
        com2 = New OleDbCommand(str2, con)
        com1.Parameters.Add("@name_org", TextBox1.Text)
        com1.Parameters.Add("@training_type", TextBox2.Text)
        com1.Parameters.Add("@course", TextBox3.Text)
        com1.Parameters.Add("@request_date", TextBox8.Text)
        com1.Parameters.Add("@start_date", TextBox4.Text)
        com1.Parameters.Add("@end_date", TextBox5.Text)
        com1.Parameters.Add("@trainees", TextBox6.Text)
        com1.Parameters.Add("@incharge_name", TextBox7.Text)

        com2.Parameters.Add("@name_org", TextBox1.Text)
        com2.Parameters.Add("@training_type", TextBox2.Text)
        com2.Parameters.Add("@course", TextBox3.Text)
        com2.Parameters.Add("@request_date", TextBox8.Text)


    End Sub

but this code is inserting the record but bt deleting those from the pendingtraining_details...
i have also swapped my executenonquery() statements but still the same result...
not getting a head out of this trap..
any help wld be gr8...

Similar Threads
Thread Thread Starter Forum Replies Last Post
Composite Foreign Key bijgupt SQL Server 2005 6 May 4th, 2007 08:46 AM
delete a composite key record from database abhi_loveu2002 ASP.NET 2.0 Basics 0 December 18th, 2006 02:12 AM
XSD composite key constraint aldwinenriquez XML 2 August 15th, 2005 04:20 AM
Composite key question hlchuah77 SQL Server 2000 3 October 19th, 2004 05:24 AM
Composite primary key evandromoreno Dreamweaver (all versions) 0 July 16th, 2004 02:12 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.