hi!
ok, im working on a database application. ive successfully managed to
establish a relationship between two tables and display them on a datagrid,
edit and add new records to them.
now i need to generate a report using the parameters in the child table, and
two columns from the parent table. this is where the problem starts. when i
use two seperate connection links and extract the required data, adding it
all to the same dataset, the information appears as if there's a blank parent
table, with two child tables. i cant get the datagrid to just treat the
dataset as one set of information and display that. (tried even the dataset.
relations.clear() without any luck)
this is the code i used:
'opening connection link to amc1 and filling only required parts of table.
link2.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data
Source = C:\amc.mdb"
link2.Open()
'emptying dataset incase form reloads
Try
ds2.Clear()
sql2 = "SELECT * FROM amc2"
da2 = New OleDb.OleDbDataAdapter(sql2, link2)
da2.Fill(ds2, "amc2")
link3.ConnectionString = "PROVIDER = Microsoft.Jet.OLEDB.4.0;Data
Source = C:\amc.mdb"
link3.Open()
sql3 = "select cus1 From amc1"
da3 = New OleDb.OleDbDataAdapter(sql3, link3)
da3.Fill(ds2, "amc1")
ds2.Relations.Clear()
dg1.DataSource = ds2
Catch ex As Exception
MsgBox("Error: " & ex.Source & ":" & ex.Message, MsgBoxStyle.
OKOnly)
End Try
End Sub
since that didnt work, ive tried copying out the information from the first
table to the child table and displaying all columns in the child table - i'd
prefer not to do this because for one thing my database will have at least
25000 rows, so it will really slow down things!
but even in this code, i get this error :
"Failed to enable constraints. One or more rows contain values violating non-
null, unique or foreign key constraints".
checked out the access table settings - there's no such violation. all the
cells have a value, i havent enabled any unique value constraint. (what's a
foreign key constraint?)
this is the code i used for this:
Private Sub appearance2()
'opening connection link to amc1 and filling only required parts of
table.
link2.ConnectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data
Source = C:\amc.mdb"
link2.Open()
'emptying dataset incase form reloads
Try
ds2.Clear()
sql2 = "SELECT * FROM amc2"
da2 = New OleDb.OleDbDataAdapter(sql2, link2)
da2.Fill(ds2, "amc2")
ds2.Relations.Clear()
dg1.DataSource = ds2
Catch ex As Exception
MsgBox("Error: " & ex.Source & ":" & ex.Message, MsgBoxStyle.
OKOnly)
End Try
End Sub
can someone please help me out? thanks a lot.
--
Message posted via DotNetMonster.com
http://www.dotnetmonster.com/Uwe/For...b-net/200601/1