Foreign Keys and Relationships

I have a problem with relationships. I have two tables in sql 2005.

one table related to another. when i'm trying to delete a row in visual basic .net it says

"Update requires a valid DeleteCommand when passed DataRow collection with deleted rows"

I did my visual basic form with drag&drop stuff with datasource wizard.

i'm managing two bingingsource with one bindingnavigator. i guess that causes this problem but maybe not?

and i've one last question. i think we can set relationships in vb.net also . what should i do? should i set these relation in sql or visual basic? maybe it could be the constraint problem.

i'm so new about this .net please help me..

heres my code

PublicClass frm_ana

PrivateSub BRD_TASARIM_TALEPBindingNavigatorSaveItem_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles BRD_TASARIM_TALEPBindingNavigatorSaveItem.Click

Try

Me.BRD_TASARIM_TALEPErrorProvider.Clear()

Me.BRD_TASARIMErrorProvider.Clear()

Me.Validate()

SelectCaseMe.TabControl1.SelectedIndex

Case 0

Me.BRD_TASARIM_TALEPBindingSource.EndEdit()

Me.BRD_TASARIM_TALEPTableAdapter.Update(Me.BNVTDataSet.BRD_TASARIM_TALEP)

Me.BRD_TASARIM_TALEPDataGridView.Refresh()

Case 1

Me.BRD_TASARIMBindingSource.EndEdit()

Me.BRD_TASARIMTableAdapter.Update(Me.BNVTDataSet.BRD_TASARIM)

Me.BRD_TASARIMDataGridView.Refresh()

EndSelect

MsgBox("??lem Tamamland?", MsgBoxStyle.Information,"Kay?tlar")

Catch

SelectCaseMe.TabControl1.SelectedIndex

Case 0

IfMe.TALEP_EDENTextBox.Text =""Then

Me.BRD_TASARIM_TALEPErrorProvider.SetError(Me.TALEP_EDENTextBox,"Bo? B?rak?lamaz")

ElseIfMe.KONUTextBox.Text =""Then

Me.BRD_TASARIM_TALEPErrorProvider.SetError(Me.KONUTextBox,"Bo? B?rak?lamaz")

Else

MsgBox("??lem Tamamlanamad?" & vbCrLf &"Hata: " & Err.Description, MsgBoxStyle.Critical,"Kay?tlar")

EndIf

Case 1

IfMe.TALEP_KODTextBox.Text =""Then

Me.BRD_TASARIMErrorProvider.SetError(Me.TALEP_KODTextBox,"Bo? B?rak?lamaz")

ElseIfMe.RAPORTextBox.Text =""Then

Me.BRD_TASARIMErrorProvider.SetError(Me.RAPORTextBox,"Bo? B?rak?lamaz")

Else

MsgBox("??lem Tamamlanamad?" & vbCrLf &"Hata: " & Err.Description, MsgBoxStyle.Critical,"Kay?tlar")

EndIf

EndSelect

EndTry

EndSub

PrivateSub Form1_Load(ByVal senderAs System.Object,ByVal eAs System.EventArgs)HandlesMyBase.Load

'TODO: This line of code loads data into the 'BNVTDataSet.BRD_TASARIM' table. You can move, or remove it, as needed.

Me.BRD_TASARIMTableAdapter.Fill(Me.BNVTDataSet.BRD_TASARIM)

'TODO: This line of code loads data into the 'BNVTDataSet.BRD_TASARIM' table. You can move, or remove it, as needed.

Me.BRD_TASARIMTableAdapter.Fill(Me.BNVTDataSet.BRD_TASARIM)

'TODO: This line of code loads data into the 'BNVTDataSet.BRD_TASARIM_TALEP' table. You can move, or remove it, as needed.

Me.BRD_TASARIM_TALEPTableAdapter.Fill(Me.BNVTDataSet.BRD_TASARIM_TALEP)

EndSub

PrivateSub tab_tasarim_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles tab_tasarim.Click

EndSub

PrivateSub TabControl1_SelectedIndexChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles TabControl1.SelectedIndexChanged

SelectCaseMe.TabControl1.SelectedIndex

Case 0

Me.BRD_TASARIM_TALEPBindingNavigator.BindingSource = BRD_TASARIM_TALEPBindingSource

Case 1

Me.BRD_TASARIM_TALEPBindingNavigator.BindingSource = BRD_TASARIMBindingSource

EndSelect

EndSub

PrivateSub BindingNavigatorDeleteItem_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles BindingNavigatorDeleteItem.Click

EndSub

EndClass

and thats my relation picture in .net

[9526 byte] By [chaostician] at [2007-12-26]
# 1

Hi,

The problem here is that you have not put the necesary logic for make that works. here is a quote a I took from a book chapter - ADO.NET the Core Reference:

"Exceptions such as these confused many developers during the Microsoft .NET Framework beta. Previous data access technologies such as ADO include features that let you submit changes automatically. With ADO.NET, you can submit changes using the DataAdapter object, but the DataAdapter does not automatically include the logic required to submit updates.

So how do you add the necessary updating logic to your ADO.NET DataAdapter? You have three basic options: you can write your own code, ask ADO.NET to generate the updating logic for you, or rely on a code generation tool such as the Visual Studio .NET Data Adapter Configuration Wizard"

This Book chapter will explain how to do this.

Best Regards

LuisD.Rojas at 2007-9-4 > top of Msdn Tech,.NET Development,.NET Framework Data Access and Storage...

.NET Development

Site Classified