Hi all,
With the help of this forum, I learned how to use the basics of .xsd Type DataSets. I was also able to use simple DataRelations, Foreign Key Constraints.
However, I encountered another problem and need some assistance.
Using the Wizard, I created a DataSet. Then I manually created the DataRelations and Foreign Key Constraints. Everything works fine as long as I don't changed anything else on my TableAdapters and DataTable.
But I need to have a Dynamic SQL for filling some of my DataTables. This is where the problem begins. My TableAdapters default SelectCommand is "SELECT * FROM video" and it works fine. But then on my screen I have an option where the use can perform a search so my SelectCommand will contain a Dynamic SQL from here. So I programmatically create a dataadapter like this.
I've made sure that all my parent datatables are being filled first, (whether or not they're being used on the screen) before I fill the child table.
Also, I clear all the datatables when I click the EnterSearch button I created. Then the codes above I put on a ExecuteSearch button.
But still it gives me the "Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints." error again on the italized line above.
I've also noticed that when you changed the SelectCommand of the TableAdapter at design time, (by going to the TableAdapters SelectCommand property) and setting it to a Select Statement with WHERE condtion something like "SELECT * FROM video WHERE video_id = 1". Then when I run the form I get an error immediately at the line where my TableAdapter Fills the Datatable.
Do DataTables with DataRelation not support SQL with WHERE conditions?
Please help... Thanks.
With the help of this forum, I learned how to use the basics of .xsd Type DataSets. I was also able to use simple DataRelations, Foreign Key Constraints.
However, I encountered another problem and need some assistance.
Using the Wizard, I created a DataSet. Then I manually created the DataRelations and Foreign Key Constraints. Everything works fine as long as I don't changed anything else on my TableAdapters and DataTable.
But I need to have a Dynamic SQL for filling some of my DataTables. This is where the problem begins. My TableAdapters default SelectCommand is "SELECT * FROM video" and it works fine. But then on my screen I have an option where the use can perform a search so my SelectCommand will contain a Dynamic SQL from here. So I programmatically create a dataadapter like this.
VB.NET:
[SIZE="2"]
Private Sub ExecuteSearch()
Dim orclConnection As New OracleConnection(Me.VIDEOTableAdapter.Connection.ConnectionString)
Dim orclCommand As New OracleCommand("SELECT * FROM video WHERE video_ID LIKE '" & txtVideoId.Text & "'", orclConnection)
Dim orclAdapter As OracleDataAdapter
orclAdapter = New OracleDataAdapter(orclCommand)
orclAdapter.Fill(Me.OrclDataset.VIDEO) 'Fill parent datatable.
Me.RENTAL_PAYMENTSTableAdapter.Fill(Me.OrclDataset.RENTAL_PAYMENTS) 'Fill parent datatable
[I]Me.RENTED_VIDEOTableAdapter.Fill(Me.OrclDataset.RENTED_VIDEO)[/I] 'Fill child datatable
End Sub[/SIZE]
I've made sure that all my parent datatables are being filled first, (whether or not they're being used on the screen) before I fill the child table.
Also, I clear all the datatables when I click the EnterSearch button I created. Then the codes above I put on a ExecuteSearch button.
But still it gives me the "Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints." error again on the italized line above.
I've also noticed that when you changed the SelectCommand of the TableAdapter at design time, (by going to the TableAdapters SelectCommand property) and setting it to a Select Statement with WHERE condtion something like "SELECT * FROM video WHERE video_id = 1". Then when I run the form I get an error immediately at the line where my TableAdapter Fills the Datatable.
Do DataTables with DataRelation not support SQL with WHERE conditions?
Please help... Thanks.
Last edited: