473,581 Members | 2,783 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to create ForeignKeyConst raint?

max

Hello,
I am a newbye, and I'm trying to write a simple application.
I have five tables with three columns; all tables are identical; I need to
change some data in the first table and let VB updates the same data in all
other four tables in the right places.
I know it would be possible by using the ForeignKeyConst raint object. I have
created the tables using the DataSet Visual Tool and I know it doesn't
create any ForeignKeyConst raint obj. I have found many codes examples on it,
but I don't know how to merge the code they in an existing dataset.

Hope somebody help.
Thanks in advance,
Max.

Dec 19 '06 #1
27 3770
What kind of database are you using? VB2003 or VB2005?
..Net 1.1 or .Net 2.0?

How are you filling your tables?

Robin S.
-------------------------------------

"max" <ma*@max.maxwro te in message
news:GY******** *********@torna do.fastwebnet.i t...
>
Hello,
I am a newbye, and I'm trying to write a simple application.
I have five tables with three columns; all tables are identical; I
need to change some data in the first table and let VB updates the
same data in all other four tables in the right places.
I know it would be possible by using the ForeignKeyConst raint object.
I have created the tables using the DataSet Visual Tool and I know it
doesn't create any ForeignKeyConst raint obj. I have found many codes
examples on it, but I don't know how to merge the code they in an
existing dataset.

Hope somebody help.
Thanks in advance,
Max.


Dec 20 '06 #2
max

Thanks for yor answer. I'm using VB2005, .Net 2.0.
Tables structure and data was developed in Access and loaded in a dataset
using the Data Source Configuration Wizard. Then I created a form, dragged
the table from the Dataset which creates a bindingnavigato r obj on top of
form; a second form load this form by a button and I correctly see the data.
There are only three columns in the tables: an incremental ID (I gave it
primary key), a number, and a name. Then I need to change, insert and delete
records in the first table and replicate this change in all the other four
tables, that are identical in structure and data. I can change and update
data in the first table (because I see that changes was really on it), but I
cannot replicate in the others. I have already tried to make relations using
Data Designer, but it doesn't work; I have read in some newsgroup that
ForeignKeyConst raint cannot be created by this way.
I'd like to understand where and how insert vb code to create relationship
between columns in the first table to all the others. I can't realize in
which vb module, vb code must be added.
Thanks for your attention and sorry for my English.
Max

"RobinS" <Ro****@NoSpam. yah.noneha scritto nel messaggio
news:0e******** *************** *******@comcast .com...
>
What kind of database are you using? VB2003 or VB2005?
.Net 1.1 or .Net 2.0?

How are you filling your tables?

Robin S.
-------------------------------------

"max" <ma*@max.maxwro te in message
news:GY******** *********@torna do.fastwebnet.i t...
>>
Hello,
I am a newbye, and I'm trying to write a simple application.
I have five tables with three columns; all tables are identical; I need
to change some data in the first table and let VB updates the same data
in all other four tables in the right places.
I know it would be possible by using the ForeignKeyConst raint object. I
have created the tables using the DataSet Visual Tool and I know it
doesn't create any ForeignKeyConst raint obj. I have found many codes
examples on it, but I don't know how to merge the code they in an
existing dataset.

Hope somebody help.
Thanks in advance,
Max.





Dec 20 '06 #3

Do you have no relationships defined between the tables
in Access? Do they not show up in the Dataset Designer?

I'm not going to swear this will work. But you could
try adding your own foreign key constraints. I'm also not
sure where you would do this, but I would guess *after* the
dataset is filled, and *before* you do the binding. (I'm
assuming you're doing the binding in code, but maybe not?)

Here's an example on setting up a foreign key constraint.
This is from David Sceppa's book ADO.Net 2.0 The Core
Reference.

This uses the Customers and Orders tables from the Northwind
database.

'how to define a foreign key constraint
'first, fill your dataset with the two tables involved
'this is mine; this is loading from SQLServer, but
' load it however you're loading it from Access
Dim ss As String = "SELECT * FROM Customers; SELECT * FROM Orders"
Dim da As New SqlDataAdapter( ss, cs) 'cs is my connectionstrin g
da.TableMapping s.Add("Table"," Customers")
da.TableMapping s.Add("Table1", "Orders")
Dim ds as New DataSet()
da.Fill(ds)

'now add the foreign key constraint
Dim fk as ForeignKeyConst raint
fk = New ForeignKeyConst raint("FK_Custo mers_Orders", _
ds.Tables("Cust omers").Columns ("CustomerID "), _
ds.Tables("Orde rs").Columns("C ustomerID"))

Maybe if you play around with the code in this example,
you can figure out some way to get it to work. If you want
more help, you're going to need to post some code.

Robin S.
----------------
"max" <ma*@max.maxwro te in message
news:19******** *********@torna do.fastwebnet.i t...
>
Thanks for yor answer. I'm using VB2005, .Net 2.0.
Tables structure and data was developed in Access and loaded in a
dataset using the Data Source Configuration Wizard. Then I created a
form, dragged the table from the Dataset which creates a
bindingnavigato r obj on top of form; a second form load this form by a
button and I correctly see the data. There are only three columns in
the tables: an incremental ID (I gave it primary key), a number, and a
name. Then I need to change, insert and delete records in the first
table and replicate this change in all the other four tables, that are
identical in structure and data. I can change and update data in the
first table (because I see that changes was really on it), but I
cannot replicate in the others. I have already tried to make relations
using Data Designer, but it doesn't work; I have read in some
newsgroup that ForeignKeyConst raint cannot be created by this way.
I'd like to understand where and how insert vb code to create
relationship between columns in the first table to all the others. I
can't realize in which vb module, vb code must be added.
Thanks for your attention and sorry for my English.
Max

"RobinS" <Ro****@NoSpam. yah.noneha scritto nel messaggio
news:0e******** *************** *******@comcast .com...
>>
What kind of database are you using? VB2003 or VB2005?
.Net 1.1 or .Net 2.0?

How are you filling your tables?

Robin S.
-------------------------------------

"max" <ma*@max.maxwro te in message
news:GY******* **********@torn ado.fastwebnet. it...
>>>
Hello,
I am a newbye, and I'm trying to write a simple application.
I have five tables with three columns; all tables are identical; I
need to change some data in the first table and let VB updates the
same data in all other four tables in the right places.
I know it would be possible by using the ForeignKeyConst raint
object. I have created the tables using the DataSet Visual Tool and
I know it doesn't create any ForeignKeyConst raint obj. I have found
many codes examples on it, but I don't know how to merge the code
they in an existing dataset.

Hope somebody help.
Thanks in advance,
Max.






Dec 21 '06 #4
max

I'm sorry, but I really can't solve the problem.
I don't have any relationships defined in Access, neither I have set in
Dataset Designer.
Trying to use your code, I'm in trouble about connection string, this is
mine (I put the code in a Form_Load environment):
Provider=Micros oft.Jet.OLEDB.4 .0;Data Source="C:\xxx\ yyy.mdb"
I get an error in "Provider", it's not recognized by SqlDataAdapter.

I have this code:

Public Class Form_modPrest1
Private Sub TblPrest1Bindin gNavigatorSaveI tem_Click(ByVal sender As
System.Object, ByVal e As System.EventArg s) Handles
TblPrest1Bindin gNavigatorSaveI tem.Click
Me.Validate()
Me.TblPrest1Bin dingSource.EndE dit()
Me.TblPrest1Tab leAdapter.Updat e(Me.GestPrestD ataSet.tblPrest 1)
End Sub
Private Sub Form_modPrest1_ Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Me.TblPrest1Tab leAdapter.Fill( Me.myDataSet.tb lPrest1)

This cames automatically from dragging the tblPrest1 from dataset to the
form, in a datagrid format. I put your code under last line. And it doesn't
work.
Because I have other four tables identical to this, I get also five forms
identical, changing only the names of form (modPrest2...) and names of
tables (tblPrest2...)
Then I load these forms by a menu, and I see the contents of all tables in
datagrid format.
Then I make a change in the tblPrest1, and save the change by clicking in
the floppy disk icon. When I reload the table, changes are effectively in
use.
It seems this procedure already fill the table in dataset... or not?
I can't understand how automatically changing the other four tables without
calling each one by one.
I'm sorry for this but I'm really at the beginning about database
programming.
Please help and thanks for your patience.

"RobinS" <Ro****@NoSpam. yah.noneha scritto nel messaggio
news:p6******** *************** *******@comcast .com...
>

Do you have no relationships defined between the tables
in Access? Do they not show up in the Dataset Designer?

I'm not going to swear this will work. But you could
try adding your own foreign key constraints. I'm also not
sure where you would do this, but I would guess *after* the
dataset is filled, and *before* you do the binding. (I'm
assuming you're doing the binding in code, but maybe not?)

Here's an example on setting up a foreign key constraint.
This is from David Sceppa's book ADO.Net 2.0 The Core
Reference.

This uses the Customers and Orders tables from the Northwind
database.

'how to define a foreign key constraint
'first, fill your dataset with the two tables involved
'this is mine; this is loading from SQLServer, but
' load it however you're loading it from Access
Dim ss As String = "SELECT * FROM Customers; SELECT * FROM Orders"
Dim da As New SqlDataAdapter( ss, cs) 'cs is my connectionstrin g
da.TableMapping s.Add("Table"," Customers")
da.TableMapping s.Add("Table1", "Orders")
Dim ds as New DataSet()
da.Fill(ds)

'now add the foreign key constraint
Dim fk as ForeignKeyConst raint
fk = New ForeignKeyConst raint("FK_Custo mers_Orders", _
ds.Tables("Cust omers").Columns ("CustomerID "), _
ds.Tables("Orde rs").Columns("C ustomerID"))

Maybe if you play around with the code in this example,
you can figure out some way to get it to work. If you want
more help, you're going to need to post some code.

Robin S.
----------------
"max" <ma*@max.maxwro te in message
news:19******** *********@torna do.fastwebnet.i t...
>>
Thanks for yor answer. I'm using VB2005, .Net 2.0.
Tables structure and data was developed in Access and loaded in a dataset
using the Data Source Configuration Wizard. Then I created a form,
dragged the table from the Dataset which creates a bindingnavigato r obj
on top of form; a second form load this form by a button and I correctly
see the data. There are only three columns in the tables: an incremental
ID (I gave it primary key), a number, and a name. Then I need to change,
insert and delete records in the first table and replicate this change in
all the other four tables, that are identical in structure and data. I
can change and update data in the first table (because I see that changes
was really on it), but I cannot replicate in the others. I have already
tried to make relations using Data Designer, but it doesn't work; I have
read in some newsgroup that ForeignKeyConst raint cannot be created by
this way.
I'd like to understand where and how insert vb code to create
relationship between columns in the first table to all the others. I
can't realize in which vb module, vb code must be added.
Thanks for your attention and sorry for my English.
Max

"RobinS" <Ro****@NoSpam. yah.noneha scritto nel messaggio
news:0e******* *************** ********@comcas t.com...
>>>
What kind of database are you using? VB2003 or VB2005?
.Net 1.1 or .Net 2.0?

How are you filling your tables?

Robin S.
-------------------------------------

"max" <ma*@max.maxwro te in message
news:GY****** ***********@tor nado.fastwebnet .it...

Hello,
I am a newbye, and I'm trying to write a simple application.
I have five tables with three columns; all tables are identical; I need
to change some data in the first table and let VB updates the same data
in all other four tables in the right places.
I know it would be possible by using the ForeignKeyConst raint object. I
have created the tables using the DataSet Visual Tool and I know it
doesn't create any ForeignKeyConst raint obj. I have found many codes
examples on it, but I don't know how to merge the code they in an
existing dataset.

Hope somebody help.
Thanks in advance,
Max.








Dec 21 '06 #5
Argh. Sorry; I didn't realize you were going to use my dataset
code. You need to use the OleDBDataAdapte r, not the SqlDataAdapter.
But you don't need that stuff if you're using a DataSet that
you set up in your DataSet designer; you only need the code defining
the Foreign Key Restraint. I included the other just to show
position.

I'm assuming you have *two* datatables in your dataset, one
being the parent and one being the child? Your code only
seems to fill one table. Where is the other one?

ds is my dataset name.
Customers is my parent table.
Orders is my child table.
CustomerID is the field in both tables that relates them
to each other.
>'now add the foreign key constraint
Dim fk as ForeignKeyConst raint
fk = New ForeignKeyConst raint("FK_Custo mers_Orders", _
ds.Tables("Cust omers").Columns ("CustomerID "), _
ds.Tables("Orde rs").Columns("C ustomerID"))
If you still can't figure it out, please re-post your code
showing the filling of the tables, probably in your form_load
routine.

And if you post more code, if you paste it into notepad and
then copy and paste it into your posting, it will be
indented properly and be easier to read.

Robin S.
-----------------------

"max" <ma*@max.maxwro te in message
news:9d******** *******@tornado .fastwebnet.it. ..
>
I'm sorry, but I really can't solve the problem.
I don't have any relationships defined in Access, neither I have set
in Dataset Designer.
Trying to use your code, I'm in trouble about connection string, this
is mine (I put the code in a Form_Load environment):
Provider=Micros oft.Jet.OLEDB.4 .0;Data Source="C:\xxx\ yyy.mdb"
I get an error in "Provider", it's not recognized by SqlDataAdapter.

I have this code:

Public Class Form_modPrest1
Private Sub TblPrest1Bindin gNavigatorSaveI tem_Click(ByVal sender As
System.Object, ByVal e As System.EventArg s) Handles
TblPrest1Bindin gNavigatorSaveI tem.Click
Me.Validate()
Me.TblPrest1Bin dingSource.EndE dit()
Me.TblPrest1Tab leAdapter.Updat e(Me.GestPrestD ataSet.tblPrest 1)
End Sub
Private Sub Form_modPrest1_ Load(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles MyBase.Load
Me.TblPrest1Tab leAdapter.Fill( Me.myDataSet.tb lPrest1)

This cames automatically from dragging the tblPrest1 from dataset to
the form, in a datagrid format. I put your code under last line. And
it doesn't work.
Because I have other four tables identical to this, I get also five
forms identical, changing only the names of form (modPrest2...) and
names of tables (tblPrest2...)
Then I load these forms by a menu, and I see the contents of all
tables in datagrid format.
Then I make a change in the tblPrest1, and save the change by clicking
in the floppy disk icon. When I reload the table, changes are
effectively in use.
It seems this procedure already fill the table in dataset... or not?
I can't understand how automatically changing the other four tables
without calling each one by one.
I'm sorry for this but I'm really at the beginning about database
programming.
Please help and thanks for your patience.

"RobinS" <Ro****@NoSpam. yah.noneha scritto nel messaggio
news:p6******** *************** *******@comcast .com...
>>

Do you have no relationships defined between the tables
in Access? Do they not show up in the Dataset Designer?

I'm not going to swear this will work. But you could
try adding your own foreign key constraints. I'm also not
sure where you would do this, but I would guess *after* the
dataset is filled, and *before* you do the binding. (I'm
assuming you're doing the binding in code, but maybe not?)

Here's an example on setting up a foreign key constraint.
This is from David Sceppa's book ADO.Net 2.0 The Core
Reference.

This uses the Customers and Orders tables from the Northwind
database.

'how to define a foreign key constraint
'first, fill your dataset with the two tables involved
'this is mine; this is loading from SQLServer, but
' load it however you're loading it from Access
Dim ss As String = "SELECT * FROM Customers; SELECT * FROM Orders"
Dim da As New SqlDataAdapter( ss, cs) 'cs is my connectionstrin g
da.TableMappin gs.Add("Table", "Customers" )
da.TableMappin gs.Add("Table1" ,"Orders")
Dim ds as New DataSet()
da.Fill(ds)

'now add the foreign key constraint
Dim fk as ForeignKeyConst raint
fk = New ForeignKeyConst raint("FK_Custo mers_Orders", _
ds.Tables("Cust omers").Columns ("CustomerID "), _
ds.Tables("Orde rs").Columns("C ustomerID"))

Maybe if you play around with the code in this example,
you can figure out some way to get it to work. If you want
more help, you're going to need to post some code.

Robin S.
----------------
"max" <ma*@max.maxwro te in message
news:19******* **********@torn ado.fastwebnet. it...
>>>
Thanks for yor answer. I'm using VB2005, .Net 2.0.
Tables structure and data was developed in Access and loaded in a
dataset using the Data Source Configuration Wizard. Then I created a
form, dragged the table from the Dataset which creates a
bindingnaviga tor obj on top of form; a second form load this form by
a button and I correctly see the data. There are only three columns
in the tables: an incremental ID (I gave it primary key), a number,
and a name. Then I need to change, insert and delete records in the
first table and replicate this change in all the other four tables,
that are identical in structure and data. I can change and update
data in the first table (because I see that changes was really on
it), but I cannot replicate in the others. I have already tried to
make relations using Data Designer, but it doesn't work; I have read
in some newsgroup that ForeignKeyConst raint cannot be created by
this way.
I'd like to understand where and how insert vb code to create
relationshi p between columns in the first table to all the others. I
can't realize in which vb module, vb code must be added.
Thanks for your attention and sorry for my English.
Max

"RobinS" <Ro****@NoSpam. yah.noneha scritto nel messaggio
news:0e****** *************** *********@comca st.com...

What kind of database are you using? VB2003 or VB2005?
.Net 1.1 or .Net 2.0?

How are you filling your tables?

Robin S.
-------------------------------------

"max" <ma*@max.maxwro te in message
news:GY***** ************@to rnado.fastwebne t.it...
>
Hello,
I am a newbye, and I'm trying to write a simple application.
I have five tables with three columns; all tables are identical; I
need to change some data in the first table and let VB updates the
same data in all other four tables in the right places.
I know it would be possible by using the ForeignKeyConst raint
object. I have created the tables using the DataSet Visual Tool
and I know it doesn't create any ForeignKeyConst raint obj. I have
found many codes examples on it, but I don't know how to merge the
code they in an existing dataset.
>
Hope somebody help.
Thanks in advance,
Max.
>
>






Dec 22 '06 #6
Max
Ok. I loaded in this form the secon table, too, and I fill it (I hope). Then
nothing, the second table remians unchanged. I'm really getting crazy.
This is the code:

Public Class Form_modPrest1
Private Sub TblPrest1Bindin gNavigatorSaveI tem_Click(ByVal sender As
System.Object, ByVal e As System.EventArg s) Handles
TblPrest1Bindin gNavigatorSaveI tem.Click
Me.Validate()
Me.TblPrest1Bin dingSource.EndE dit()
Me.TblPrest1Tab leAdapter.Updat e(Me.GestPrestD ataSet.tblPrest 1)
End Sub
Private Sub Form_modPrest1_ Load(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles MyBase.Load
Me.TblPrest2Tab leAdapter.Fill( Me.GestPrestDat aSet.tblPrest2)
'TODO: questa riga di codice carica i dati nella tabella
'GestPrestDataS et.tblPrest1'. È possibile spostarla o rimuoverla se
necessario.
Me.TblPrest1Tab leAdapter.Fill( Me.GestPrestDat aSet.tblPrest1)
Dim fk As ForeignKeyConst raint
fk = New ForeignKeyConst raint("FK_tbl1_ tbl2", _
GestPrestDataSe t.Tables("tblPr est1").Columns( "NomePrest" ), _
GestPrestDataSe t.Tables("tblPr est2").Columns( "NomePrest" ))
End Sub
End Class

Thanks Robin

"RobinS" <Ro****@NoSpam. yah.noneha scritto nel messaggio
news:AL******** *************** *******@comcast .com...
Argh. Sorry; I didn't realize you were going to use my dataset
code. You need to use the OleDBDataAdapte r, not the SqlDataAdapter.
But you don't need that stuff if you're using a DataSet that
you set up in your DataSet designer; you only need the code defining
the Foreign Key Restraint. I included the other just to show
position.

I'm assuming you have *two* datatables in your dataset, one
being the parent and one being the child? Your code only
seems to fill one table. Where is the other one?

ds is my dataset name.
Customers is my parent table.
Orders is my child table.
CustomerID is the field in both tables that relates them
to each other.
>>'now add the foreign key constraint
Dim fk as ForeignKeyConst raint
fk = New ForeignKeyConst raint("FK_Custo mers_Orders", _
ds.Tables("Cust omers").Columns ("CustomerID "), _
ds.Tables("Orde rs").Columns("C ustomerID"))

If you still can't figure it out, please re-post your code
showing the filling of the tables, probably in your form_load
routine.

And if you post more code, if you paste it into notepad and
then copy and paste it into your posting, it will be
indented properly and be easier to read.

Robin S.
-----------------------

"max" <ma*@max.maxwro te in message
news:9d******** *******@tornado .fastwebnet.it. ..
>>
I'm sorry, but I really can't solve the problem.
I don't have any relationships defined in Access, neither I have set in
Dataset Designer.
Trying to use your code, I'm in trouble about connection string, this is
mine (I put the code in a Form_Load environment):
Provider=Micro soft.Jet.OLEDB. 4.0;Data Source="C:\xxx\ yyy.mdb"
I get an error in "Provider", it's not recognized by SqlDataAdapter.

I have this code:

Public Class Form_modPrest1
Private Sub TblPrest1Bindin gNavigatorSaveI tem_Click(ByVal sender As
System.Objec t, ByVal e As System.EventArg s) Handles
TblPrest1Bindi ngNavigatorSave Item.Click
Me.Validate( )
Me.TblPrest1Bi ndingSource.End Edit()
Me.TblPrest1Ta bleAdapter.Upda te(Me.GestPrest DataSet.tblPres t1)
End Sub
Private Sub Form_modPrest1_ Load(ByVal sender As System.Object, ByVal e As
System.EventAr gs) Handles MyBase.Load
Me.TblPrest1Ta bleAdapter.Fill (Me.myDataSet.t blPrest1)

This cames automatically from dragging the tblPrest1 from dataset to the
form, in a datagrid format. I put your code under last line. And it
doesn't work.
Because I have other four tables identical to this, I get also five forms
identical, changing only the names of form (modPrest2...) and names of
tables (tblPrest2...)
Then I load these forms by a menu, and I see the contents of all tables
in datagrid format.
Then I make a change in the tblPrest1, and save the change by clicking in
the floppy disk icon. When I reload the table, changes are effectively in
use.
It seems this procedure already fill the table in dataset... or not?
I can't understand how automatically changing the other four tables
without calling each one by one.
I'm sorry for this but I'm really at the beginning about database
programming.
Please help and thanks for your patience.

"RobinS" <Ro****@NoSpam. yah.noneha scritto nel messaggio
news:p6******* *************** ********@comcas t.com...
>>>

Do you have no relationships defined between the tables
in Access? Do they not show up in the Dataset Designer?

I'm not going to swear this will work. But you could
try adding your own foreign key constraints. I'm also not
sure where you would do this, but I would guess *after* the
dataset is filled, and *before* you do the binding. (I'm
assuming you're doing the binding in code, but maybe not?)

Here's an example on setting up a foreign key constraint.
This is from David Sceppa's book ADO.Net 2.0 The Core
Reference.

This uses the Customers and Orders tables from the Northwind
database.

'how to define a foreign key constraint
'first, fill your dataset with the two tables involved
'this is mine; this is loading from SQLServer, but
' load it however you're loading it from Access
Dim ss As String = "SELECT * FROM Customers; SELECT * FROM Orders"
Dim da As New SqlDataAdapter( ss, cs) 'cs is my connectionstrin g
da.TableMappi ngs.Add("Table" ,"Customers" )
da.TableMappi ngs.Add("Table1 ","Orders")
Dim ds as New DataSet()
da.Fill(ds)

'now add the foreign key constraint
Dim fk as ForeignKeyConst raint
fk = New ForeignKeyConst raint("FK_Custo mers_Orders", _
ds.Tables("Cust omers").Columns ("CustomerID "), _
ds.Tables("Orde rs").Columns("C ustomerID"))

Maybe if you play around with the code in this example,
you can figure out some way to get it to work. If you want
more help, you're going to need to post some code.

Robin S.
----------------
"max" <ma*@max.maxwro te in message
news:19****** ***********@tor nado.fastwebnet .it...

Thanks for yor answer. I'm using VB2005, .Net 2.0.
Tables structure and data was developed in Access and loaded in a
dataset using the Data Source Configuration Wizard. Then I created a
form, dragged the table from the Dataset which creates a
bindingnavig ator obj on top of form; a second form load this form by a
button and I correctly see the data. There are only three columns in
the tables: an incremental ID (I gave it primary key), a number, and a
name. Then I need to change, insert and delete records in the first
table and replicate this change in all the other four tables, that are
identical in structure and data. I can change and update data in the
first table (because I see that changes was really on it), but I cannot
replicate in the others. I have already tried to make relations using
Data Designer, but it doesn't work; I have read in some newsgroup that
ForeignKeyCo nstraint cannot be created by this way.
I'd like to understand where and how insert vb code to create
relationsh ip between columns in the first table to all the others. I
can't realize in which vb module, vb code must be added.
Thanks for your attention and sorry for my English.
Max

"RobinS" <Ro****@NoSpam. yah.noneha scritto nel messaggio
news:0e***** *************** **********@comc ast.com...
>
What kind of database are you using? VB2003 or VB2005?
.Net 1.1 or .Net 2.0?
>
How are you filling your tables?
>
Robin S.
-------------------------------------
>
"max" <ma*@max.maxwro te in message
news:GY**** *************@t ornado.fastwebn et.it...
>>
>Hello,
>I am a newbye, and I'm trying to write a simple application.
>I have five tables with three columns; all tables are identical; I
>need to change some data in the first table and let VB updates the
>same data in all other four tables in the right places.
>I know it would be possible by using the ForeignKeyConst raint object.
>I have created the tables using the DataSet Visual Tool and I know it
>doesn't create any ForeignKeyConst raint obj. I have found many codes
>examples on it, but I don't know how to merge the code they in an
>existing dataset.
>>
>Hope somebody help.
>Thanks in advance,
>Max.
>>
>>
>
>
>





"RobinS" <Ro****@NoSpam. yah.noneha scritto nel messaggio
news:AL******** *************** *******@comcast .com...
Argh. Sorry; I didn't realize you were going to use my dataset
code. You need to use the OleDBDataAdapte r, not the SqlDataAdapter.
But you don't need that stuff if you're using a DataSet that
you set up in your DataSet designer; you only need the code defining
the Foreign Key Restraint. I included the other just to show
position.

I'm assuming you have *two* datatables in your dataset, one
being the parent and one being the child? Your code only
seems to fill one table. Where is the other one?

ds is my dataset name.
Customers is my parent table.
Orders is my child table.
CustomerID is the field in both tables that relates them
to each other.
>>'now add the foreign key constraint
Dim fk as ForeignKeyConst raint
fk = New ForeignKeyConst raint("FK_Custo mers_Orders", _
ds.Tables("Cust omers").Columns ("CustomerID "), _
ds.Tables("Orde rs").Columns("C ustomerID"))

If you still can't figure it out, please re-post your code
showing the filling of the tables, probably in your form_load
routine.

And if you post more code, if you paste it into notepad and
then copy and paste it into your posting, it will be
indented properly and be easier to read.

Robin S.
-----------------------

"max" <ma*@max.maxwro te in message
news:9d******** *******@tornado .fastwebnet.it. ..
>>
I'm sorry, but I really can't solve the problem.
I don't have any relationships defined in Access, neither I have set in
Dataset Designer.
Trying to use your code, I'm in trouble about connection string, this is
mine (I put the code in a Form_Load environment):
Provider=Micro soft.Jet.OLEDB. 4.0;Data Source="C:\xxx\ yyy.mdb"
I get an error in "Provider", it's not recognized by SqlDataAdapter.

I have this code:

Public Class Form_modPrest1
Private Sub TblPrest1Bindin gNavigatorSaveI tem_Click(ByVal sender As
System.Objec t, ByVal e As System.EventArg s) Handles
TblPrest1Bindi ngNavigatorSave Item.Click
Me.Validate( )
Me.TblPrest1Bi ndingSource.End Edit()
Me.TblPrest1Ta bleAdapter.Upda te(Me.GestPrest DataSet.tblPres t1)
End Sub
Private Sub Form_modPrest1_ Load(ByVal sender As System.Object, ByVal e As
System.EventAr gs) Handles MyBase.Load
Me.TblPrest1Ta bleAdapter.Fill (Me.myDataSet.t blPrest1)

This cames automatically from dragging the tblPrest1 from dataset to the
form, in a datagrid format. I put your code under last line. And it
doesn't work.
Because I have other four tables identical to this, I get also five forms
identical, changing only the names of form (modPrest2...) and names of
tables (tblPrest2...)
Then I load these forms by a menu, and I see the contents of all tables
in datagrid format.
Then I make a change in the tblPrest1, and save the change by clicking in
the floppy disk icon. When I reload the table, changes are effectively in
use.
It seems this procedure already fill the table in dataset... or not?
I can't understand how automatically changing the other four tables
without calling each one by one.
I'm sorry for this but I'm really at the beginning about database
programming.
Please help and thanks for your patience.

"RobinS" <Ro****@NoSpam. yah.noneha scritto nel messaggio
news:p6******* *************** ********@comcas t.com...
>>>

Do you have no relationships defined between the tables
in Access? Do they not show up in the Dataset Designer?

I'm not going to swear this will work. But you could
try adding your own foreign key constraints. I'm also not
sure where you would do this, but I would guess *after* the
dataset is filled, and *before* you do the binding. (I'm
assuming you're doing the binding in code, but maybe not?)

Here's an example on setting up a foreign key constraint.
This is from David Sceppa's book ADO.Net 2.0 The Core
Reference.

This uses the Customers and Orders tables from the Northwind
database.

'how to define a foreign key constraint
'first, fill your dataset with the two tables involved
'this is mine; this is loading from SQLServer, but
' load it however you're loading it from Access
Dim ss As String = "SELECT * FROM Customers; SELECT * FROM Orders"
Dim da As New SqlDataAdapter( ss, cs) 'cs is my connectionstrin g
da.TableMappi ngs.Add("Table" ,"Customers" )
da.TableMappi ngs.Add("Table1 ","Orders")
Dim ds as New DataSet()
da.Fill(ds)

'now add the foreign key constraint
Dim fk as ForeignKeyConst raint
fk = New ForeignKeyConst raint("FK_Custo mers_Orders", _
ds.Tables("Cust omers").Columns ("CustomerID "), _
ds.Tables("Orde rs").Columns("C ustomerID"))

Maybe if you play around with the code in this example,
you can figure out some way to get it to work. If you want
more help, you're going to need to post some code.

Robin S.
----------------
"max" <ma*@max.maxwro te in message
news:19****** ***********@tor nado.fastwebnet .it...

Thanks for yor answer. I'm using VB2005, .Net 2.0.
Tables structure and data was developed in Access and loaded in a
dataset using the Data Source Configuration Wizard. Then I created a
form, dragged the table from the Dataset which creates a
bindingnavig ator obj on top of form; a second form load this form by a
button and I correctly see the data. There are only three columns in
the tables: an incremental ID (I gave it primary key), a number, and a
name. Then I need to change, insert and delete records in the first
table and replicate this change in all the other four tables, that are
identical in structure and data. I can change and update data in the
first table (because I see that changes was really on it), but I cannot
replicate in the others. I have already tried to make relations using
Data Designer, but it doesn't work; I have read in some newsgroup that
ForeignKeyCo nstraint cannot be created by this way.
I'd like to understand where and how insert vb code to create
relationsh ip between columns in the first table to all the others. I
can't realize in which vb module, vb code must be added.
Thanks for your attention and sorry for my English.
Max

"RobinS" <Ro****@NoSpam. yah.noneha scritto nel messaggio
news:0e***** *************** **********@comc ast.com...
>
What kind of database are you using? VB2003 or VB2005?
.Net 1.1 or .Net 2.0?
>
How are you filling your tables?
>
Robin S.
-------------------------------------
>
"max" <ma*@max.maxwro te in message
news:GY**** *************@t ornado.fastwebn et.it...
>>
>Hello,
>I am a newbye, and I'm trying to write a simple application.
>I have five tables with three columns; all tables are identical; I
>need to change some data in the first table and let VB updates the
>same data in all other four tables in the right places.
>I know it would be possible by using the ForeignKeyConst raint object.
>I have created the tables using the DataSet Visual Tool and I know it
>doesn't create any ForeignKeyConst raint obj. I have found many codes
>examples on it, but I don't know how to merge the code they in an
>existing dataset.
>>
>Hope somebody help.
>Thanks in advance,
>Max.
>>
>>
>
>
>





"RobinS" <Ro****@NoSpam. yah.noneha scritto nel messaggio
news:AL******** *************** *******@comcast .com...
Argh. Sorry; I didn't realize you were going to use my dataset
code. You need to use the OleDBDataAdapte r, not the SqlDataAdapter.
But you don't need that stuff if you're using a DataSet that
you set up in your DataSet designer; you only need the code defining
the Foreign Key Restraint. I included the other just to show
position.

I'm assuming you have *two* datatables in your dataset, one
being the parent and one being the child? Your code only
seems to fill one table. Where is the other one?

ds is my dataset name.
Customers is my parent table.
Orders is my child table.
CustomerID is the field in both tables that relates them
to each other.
>>'now add the foreign key constraint
Dim fk as ForeignKeyConst raint
fk = New ForeignKeyConst raint("FK_Custo mers_Orders", _
ds.Tables("Cust omers").Columns ("CustomerID "), _
ds.Tables("Orde rs").Columns("C ustomerID"))

If you still can't figure it out, please re-post your code
showing the filling of the tables, probably in your form_load
routine.

And if you post more code, if you paste it into notepad and
then copy and paste it into your posting, it will be
indented properly and be easier to read.

Robin S.
-----------------------

"max" <ma*@max.maxwro te in message
news:9d******** *******@tornado .fastwebnet.it. ..
>>
I'm sorry, but I really can't solve the problem.
I don't have any relationships defined in Access, neither I have set in
Dataset Designer.
Trying to use your code, I'm in trouble about connection string, this is
mine (I put the code in a Form_Load environment):
Provider=Micro soft.Jet.OLEDB. 4.0;Data Source="C:\xxx\ yyy.mdb"
I get an error in "Provider", it's not recognized by SqlDataAdapter.

I have this code:

Public Class Form_modPrest1
Private Sub TblPrest1Bindin gNavigatorSaveI tem_Click(ByVal sender As
System.Objec t, ByVal e As System.EventArg s) Handles
TblPrest1Bindi ngNavigatorSave Item.Click
Me.Validate( )
Me.TblPrest1Bi ndingSource.End Edit()
Me.TblPrest1Ta bleAdapter.Upda te(Me.GestPrest DataSet.tblPres t1)
End Sub
Private Sub Form_modPrest1_ Load(ByVal sender As System.Object, ByVal e As
System.EventAr gs) Handles MyBase.Load
Me.TblPrest1Ta bleAdapter.Fill (Me.myDataSet.t blPrest1)

This cames automatically from dragging the tblPrest1 from dataset to the
form, in a datagrid format. I put your code under last line. And it
doesn't work.
Because I have other four tables identical to this, I get also five forms
identical, changing only the names of form (modPrest2...) and names of
tables (tblPrest2...)
Then I load these forms by a menu, and I see the contents of all tables
in datagrid format.
Then I make a change in the tblPrest1, and save the change by clicking in
the floppy disk icon. When I reload the table, changes are effectively in
use.
It seems this procedure already fill the table in dataset... or not?
I can't understand how automatically changing the other four tables
without calling each one by one.
I'm sorry for this but I'm really at the beginning about database
programming.
Please help and thanks for your patience.

"RobinS" <Ro****@NoSpam. yah.noneha scritto nel messaggio
news:p6******* *************** ********@comcas t.com...
>>>

Do you have no relationships defined between the tables
in Access? Do they not show up in the Dataset Designer?

I'm not going to swear this will work. But you could
try adding your own foreign key constraints. I'm also not
sure where you would do this, but I would guess *after* the
dataset is filled, and *before* you do the binding. (I'm
assuming you're doing the binding in code, but maybe not?)

Here's an example on setting up a foreign key constraint.
This is from David Sceppa's book ADO.Net 2.0 The Core
Reference.

This uses the Customers and Orders tables from the Northwind
database.

'how to define a foreign key constraint
'first, fill your dataset with the two tables involved
'this is mine; this is loading from SQLServer, but
' load it however you're loading it from Access
Dim ss As String = "SELECT * FROM Customers; SELECT * FROM Orders"
Dim da As New SqlDataAdapter( ss, cs) 'cs is my connectionstrin g
da.TableMappi ngs.Add("Table" ,"Customers" )
da.TableMappi ngs.Add("Table1 ","Orders")
Dim ds as New DataSet()
da.Fill(ds)

'now add the foreign key constraint
Dim fk as ForeignKeyConst raint
fk = New ForeignKeyConst raint("FK_Custo mers_Orders", _
ds.Tables("Cust omers").Columns ("CustomerID "), _
ds.Tables("Orde rs").Columns("C ustomerID"))

Maybe if you play around with the code in this example,
you can figure out some way to get it to work. If you want
more help, you're going to need to post some code.

Robin S.
----------------
"max" <ma*@max.maxwro te in message
news:19****** ***********@tor nado.fastwebnet .it...

Thanks for yor answer. I'm using VB2005, .Net 2.0.
Tables structure and data was developed in Access and loaded in a
dataset using the Data Source Configuration Wizard. Then I created a
form, dragged the table from the Dataset which creates a
bindingnavig ator obj on top of form; a second form load this form by a
button and I correctly see the data. There are only three columns in
the tables: an incremental ID (I gave it primary key), a number, and a
name. Then I need to change, insert and delete records in the first
table and replicate this change in all the other four tables, that are
identical in structure and data. I can change and update data in the
first table (because I see that changes was really on it), but I cannot
replicate in the others. I have already tried to make relations using
Data Designer, but it doesn't work; I have read in some newsgroup that
ForeignKeyCo nstraint cannot be created by this way.
I'd like to understand where and how insert vb code to create
relationsh ip between columns in the first table to all the others. I
can't realize in which vb module, vb code must be added.
Thanks for your attention and sorry for my English.
Max

"RobinS" <Ro****@NoSpam. yah.noneha scritto nel messaggio
news:0e***** *************** **********@comc ast.com...
>
What kind of database are you using? VB2003 or VB2005?
.Net 1.1 or .Net 2.0?
>
How are you filling your tables?
>
Robin S.
-------------------------------------
>
"max" <ma*@max.maxwro te in message
news:GY**** *************@t ornado.fastwebn et.it...
>>
>Hello,
>I am a newbye, and I'm trying to write a simple application.
>I have five tables with three columns; all tables are identical; I
>need to change some data in the first table and let VB updates the
>same data in all other four tables in the right places.
>I know it would be possible by using the ForeignKeyConst raint object.
>I have created the tables using the DataSet Visual Tool and I know it
>doesn't create any ForeignKeyConst raint obj. I have found many codes
>examples on it, but I don't know how to merge the code they in an
>existing dataset.
>>
>Hope somebody help.
>Thanks in advance,
>Max.
>>
>>
>
>
>





Dec 22 '06 #7
Max
Sorry for the unwanted replication of messages.
Dec 22 '06 #8
I forgot to tell you to add the constraint to the table definition.
Oops. Here's some code, with the line(s) I missed (look for the
asterisks).

Here's a working example. I set up a dataset for Northwind
with Customers and Orders and deleted the constraint that was
generated so I could create one in code. Customers corresponds
to your table1; Orders corresponds to your table2.

I didn't try modifying any of my data because I don't want to muck
up my data, but it should work. (famous last words)

----------
Dim ds As NorthwindDataSe t = New NorthwindDataSe t()
Dim custAdapter As CustomersTableA dapter = New CustomersTableA dapter()
custAdapter.Fil l(ds.Customers)
Dim orderAdapter As OrdersTableAdap ter = New OrdersTableAdap ter()
orderAdapter.Fi ll(ds.Orders)

Dim fk As ForeignKeyConst raint
fk = New ForeignKeyConst raint("FK_Custo mers_Orders", _
ds.Tables("Cust omers").Columns ("CustomerID "), _
ds.Tables("Orde rs").Columns("C ustomerID"))

'***THIS IS THE STEP I FORGOT TO INCLUDE -- Oops!
ds.Tables("Orde rs").Constraint s.Add(fk)
ds.EnforceConst raints = True

'Note: You can use the data relation created by the fk
' constraint to read through your data:

Dim rowCustomer As NorthwindDataSe t.CustomersRow
Dim rowOrder As NorthwindDataSe t.OrdersRow
Dim rel As DataRelation = ds.Relations("F K_Customers_Ord ers")
For Each rowCustomer In ds.Customers
Console.WriteLi ne("Orders for {0}", rowCustomer.Com panyName)
For Each rowOrder In rowCustomer.Get ChildRows(rel)
Console.WriteLi ne(" {0} - {1:d}", rowOrder.OrderI D,
rowOrder.OrderD ate)
Next rowOrder
Next rowCustomer

And here's something else I figured out: You *can* add the constraint
to your DataSet in the DataSet Designer.

To add a DataRelation, right-click on any item in the DataSet designer
(like in your table definition) and select Add and then Relation.

You can select the parent and child tables using the drop-down lists
at the top of the dialog box, and then the datacolumns just below
that.

The lower half of that dialog box lets you control whether the action
will create a DataRelation, a ForeignKeyConst raint, or both. The
default is just DataRelation, but you should choose ForeignKey or
Both. You can also specify values for the UpdateRule, DeleteRule,
and AcceptRejectCha ngesRule on the FK constraint. It defaults to
Cascade, Cascade, and None, which is fine.

If you have all of your tables in one DataSet that you created
through the DAtaSet designer, you can try adding the constraints
there. If you ever re-create the DataSet, you have to remember
to add the constraints, too, though.

Hope this helps.
Robin S.
-----------------------------------------------------------------
"Max" <no****@devnull .spamcop.netwro te in message
news:45******** **************@ news.tiscali.it ...
Ok. I loaded in this form the secon table, too, and I fill it (I
hope). Then
nothing, the second table remians unchanged. I'm really getting crazy.
This is the code:

Public Class Form_modPrest1
Private Sub TblPrest1Bindin gNavigatorSaveI tem_Click(ByVal sender As
System.Object, ByVal e As System.EventArg s) Handles
TblPrest1Bindin gNavigatorSaveI tem.Click
Me.Validate()
Me.TblPrest1Bin dingSource.EndE dit()
Me.TblPrest1Tab leAdapter.Updat e(Me.GestPrestD ataSet.tblPrest 1)
End Sub
Private Sub Form_modPrest1_ Load(ByVal sender As System.Object,
ByVal e
As System.EventArg s) Handles MyBase.Load
Me.TblPrest2Tab leAdapter.Fill( Me.GestPrestDat aSet.tblPrest2)
'TODO: questa riga di codice carica i dati nella tabella
'GestPrestDataS et.tblPrest1'. È possibile spostarla o rimuoverla se
necessario.
Me.TblPrest1Tab leAdapter.Fill( Me.GestPrestDat aSet.tblPrest1)
Dim fk As ForeignKeyConst raint
fk = New ForeignKeyConst raint("FK_tbl1_ tbl2", _
GestPrestDataSe t.Tables("tblPr est1").Columns( "NomePrest" ),
_
GestPrestDataSe t.Tables("tblPr est2").Columns( "NomePrest" ))
End Sub
End Class

Thanks Robin

"RobinS" <Ro****@NoSpam. yah.noneha scritto nel messaggio
news:AL******** *************** *******@comcast .com...
>Argh. Sorry; I didn't realize you were going to use my dataset
code. You need to use the OleDBDataAdapte r, not the SqlDataAdapter.
But you don't need that stuff if you're using a DataSet that
you set up in your DataSet designer; you only need the code defining
the Foreign Key Restraint. I included the other just to show
position.

I'm assuming you have *two* datatables in your dataset, one
being the parent and one being the child? Your code only
seems to fill one table. Where is the other one?

ds is my dataset name.
Customers is my parent table.
Orders is my child table.
CustomerID is the field in both tables that relates them
to each other.
>>>'now add the foreign key constraint
Dim fk as ForeignKeyConst raint
fk = New ForeignKeyConst raint("FK_Custo mers_Orders", _
ds.Tables("Cust omers").Columns ("CustomerID "), _
ds.Tables("Orde rs").Columns("C ustomerID"))

If you still can't figure it out, please re-post your code
showing the filling of the tables, probably in your form_load
routine.

And if you post more code, if you paste it into notepad and
then copy and paste it into your posting, it will be
indented properly and be easier to read.

Robin S.
-----------------------

"max" <ma*@max.maxwro te in message
news:9d******* ********@tornad o.fastwebnet.it ...
>>>
I'm sorry, but I really can't solve the problem.
I don't have any relationships defined in Access, neither I have set
in Dataset Designer.
Trying to use your code, I'm in trouble about connection string,
this is mine (I put the code in a Form_Load environment):
Provider=Micr osoft.Jet.OLEDB .4.0;Data Source="C:\xxx\ yyy.mdb"
I get an error in "Provider", it's not recognized by SqlDataAdapter.

I have this code:

Public Class Form_modPrest1
Private Sub TblPrest1Bindin gNavigatorSaveI tem_Click(ByVal sender As
System.Object , ByVal e As System.EventArg s) Handles
TblPrest1Bind ingNavigatorSav eItem.Click
Me.Validate ()
Me.TblPrest1B indingSource.En dEdit()
Me.TblPrest1T ableAdapter.Upd ate(Me.GestPres tDataSet.tblPre st1)
End Sub
Private Sub Form_modPrest1_ Load(ByVal sender As System.Object, ByVal
e As System.EventArg s) Handles MyBase.Load
Me.TblPrest1T ableAdapter.Fil l(Me.myDataSet. tblPrest1)

This cames automatically from dragging the tblPrest1 from dataset to
the form, in a datagrid format. I put your code under last line. And
it doesn't work.
Because I have other four tables identical to this, I get also five
forms identical, changing only the names of form (modPrest2...) and
names of tables (tblPrest2...)
Then I load these forms by a menu, and I see the contents of all
tables in datagrid format.
Then I make a change in the tblPrest1, and save the change by
clicking in the floppy disk icon. When I reload the table, changes
are effectively in use.
It seems this procedure already fill the table in dataset... or not?
I can't understand how automatically changing the other four tables
without calling each one by one.
I'm sorry for this but I'm really at the beginning about database
programming .
Please help and thanks for your patience.

"RobinS" <Ro****@NoSpam. yah.noneha scritto nel messaggio
news:p6****** *************** *********@comca st.com...
Do you have no relationships defined between the tables
in Access? Do they not show up in the Dataset Designer?

I'm not going to swear this will work. But you could
try adding your own foreign key constraints. I'm also not
sure where you would do this, but I would guess *after* the
dataset is filled, and *before* you do the binding. (I'm
assuming you're doing the binding in code, but maybe not?)

Here's an example on setting up a foreign key constraint.
This is from David Sceppa's book ADO.Net 2.0 The Core
Reference.

This uses the Customers and Orders tables from the Northwind
database.

'how to define a foreign key constraint
'first, fill your dataset with the two tables involved
'this is mine; this is loading from SQLServer, but
' load it however you're loading it from Access
Dim ss As String = "SELECT * FROM Customers; SELECT * FROM Orders"
Dim da As New SqlDataAdapter( ss, cs) 'cs is my connectionstrin g
da.TableMapp ings.Add("Table ","Customer s")
da.TableMapp ings.Add("Table 1","Orders")
Dim ds as New DataSet()
da.Fill(ds )

'now add the foreign key constraint
Dim fk as ForeignKeyConst raint
fk = New ForeignKeyConst raint("FK_Custo mers_Orders", _
ds.Tables("Cust omers").Columns ("CustomerID "), _
ds.Tables("Orde rs").Columns("C ustomerID"))

Maybe if you play around with the code in this example,
you can figure out some way to get it to work. If you want
more help, you're going to need to post some code.

Robin S.
----------------
"max" <ma*@max.maxwro te in message
news:19***** ************@to rnado.fastwebne t.it...
>
Thanks for yor answer. I'm using VB2005, .Net 2.0.
Tables structure and data was developed in Access and loaded in a
dataset using the Data Source Configuration Wizard. Then I created
a form, dragged the table from the Dataset which creates a
bindingnavi gator obj on top of form; a second form load this form
by a button and I correctly see the data. There are only three
columns in the tables: an incremental ID (I gave it primary key),
a number, and a name. Then I need to change, insert and delete
records in the first table and replicate this change in all the
other four tables, that are identical in structure and data. I can
change and update data in the first table (because I see that
changes was really on it), but I cannot replicate in the others. I
have already tried to make relations using Data Designer, but it
doesn't work; I have read in some newsgroup that
ForeignKeyC onstraint cannot be created by this way.
I'd like to understand where and how insert vb code to create
relationshi p between columns in the first table to all the others.
I can't realize in which vb module, vb code must be added.
Thanks for your attention and sorry for my English.
Max
>
"RobinS" <Ro****@NoSpam. yah.noneha scritto nel messaggio
news:0e**** *************** ***********@com cast.com...
>>
>What kind of database are you using? VB2003 or VB2005?
>.Net 1.1 or .Net 2.0?
>>
>How are you filling your tables?
>>
>Robin S.
>-------------------------------------
>>
>"max" <ma*@max.maxwro te in message
>news:GY*** **************@ tornado.fastweb net.it...
>>>
>>Hello,
>>I am a newbye, and I'm trying to write a simple application.
>>I have five tables with three columns; all tables are identical;
>>I need to change some data in the first table and let VB updates
>>the same data in all other four tables in the right places.
>>I know it would be possible by using the ForeignKeyConst raint
>>object. I have created the tables using the DataSet Visual Tool
>>and I know it doesn't create any ForeignKeyConst raint obj. I
>>have found many codes examples on it, but I don't know how to
>>merge the code they in an existing dataset.
>>>
>>Hope somebody help.
>>Thanks in advance,
>>Max.
>>>
>>>
>>
>>
>>
>
>
>




"RobinS" <Ro****@NoSpam. yah.noneha scritto nel messaggio
news:AL******** *************** *******@comcast .com...
>Argh. Sorry; I didn't realize you were going to use my dataset
code. You need to use the OleDBDataAdapte r, not the SqlDataAdapter.
But you don't need that stuff if you're using a DataSet that
you set up in your DataSet designer; you only need the code defining
the Foreign Key Restraint. I included the other just to show
position.

I'm assuming you have *two* datatables in your dataset, one
being the parent and one being the child? Your code only
seems to fill one table. Where is the other one?

ds is my dataset name.
Customers is my parent table.
Orders is my child table.
CustomerID is the field in both tables that relates them
to each other.
>>>'now add the foreign key constraint
Dim fk as ForeignKeyConst raint
fk = New ForeignKeyConst raint("FK_Custo mers_Orders", _
ds.Tables("Cust omers").Columns ("CustomerID "), _
ds.Tables("Orde rs").Columns("C ustomerID"))

If you still can't figure it out, please re-post your code
showing the filling of the tables, probably in your form_load
routine.

And if you post more code, if you paste it into notepad and
then copy and paste it into your posting, it will be
indented properly and be easier to read.

Robin S.
-----------------------

"max" <ma*@max.maxwro te in message
news:9d******* ********@tornad o.fastwebnet.it ...
>>>
I'm sorry, but I really can't solve the problem.
I don't have any relationships defined in Access, neither I have set
in Dataset Designer.
Trying to use your code, I'm in trouble about connection string,
this is mine (I put the code in a Form_Load environment):
Provider=Micr osoft.Jet.OLEDB .4.0;Data Source="C:\xxx\ yyy.mdb"
I get an error in "Provider", it's not recognized by SqlDataAdapter.

I have this code:

Public Class Form_modPrest1
Private Sub TblPrest1Bindin gNavigatorSaveI tem_Click(ByVal sender As
System.Object , ByVal e As System.EventArg s) Handles
TblPrest1Bind ingNavigatorSav eItem.Click
Me.Validate ()
Me.TblPrest1B indingSource.En dEdit()
Me.TblPrest1T ableAdapter.Upd ate(Me.GestPres tDataSet.tblPre st1)
End Sub
Private Sub Form_modPrest1_ Load(ByVal sender As System.Object, ByVal
e As System.EventArg s) Handles MyBase.Load
Me.TblPrest1T ableAdapter.Fil l(Me.myDataSet. tblPrest1)

This cames automatically from dragging the tblPrest1 from dataset to
the form, in a datagrid format. I put your code under last line. And
it doesn't work.
Because I have other four tables identical to this, I get also five
forms identical, changing only the names of form (modPrest2...) and
names of tables (tblPrest2...)
Then I load these forms by a menu, and I see the contents of all
tables in datagrid format.
Then I make a change in the tblPrest1, and save the change by
clicking in the floppy disk icon. When I reload the table, changes
are effectively in use.
It seems this procedure already fill the table in dataset... or not?
I can't understand how automatically changing the other four tables
without calling each one by one.
I'm sorry for this but I'm really at the beginning about database
programming .
Please help and thanks for your patience.

"RobinS" <Ro****@NoSpam. yah.noneha scritto nel messaggio
news:p6****** *************** *********@comca st.com...
Do you have no relationships defined between the tables
in Access? Do they not show up in the Dataset Designer?

I'm not going to swear this will work. But you could
try adding your own foreign key constraints. I'm also not
sure where you would do this, but I would guess *after* the
dataset is filled, and *before* you do the binding. (I'm
assuming you're doing the binding in code, but maybe not?)

Here's an example on setting up a foreign key constraint.
This is from David Sceppa's book ADO.Net 2.0 The Core
Reference.

This uses the Customers and Orders tables from the Northwind
database.

'how to define a foreign key constraint
'first, fill your dataset with the two tables involved
'this is mine; this is loading from SQLServer, but
' load it however you're loading it from Access
Dim ss As String = "SELECT * FROM Customers; SELECT * FROM Orders"
Dim da As New SqlDataAdapter( ss, cs) 'cs is my connectionstrin g
da.TableMapp ings.Add("Table ","Customer s")
da.TableMapp ings.Add("Table 1","Orders")
Dim ds as New DataSet()
da.Fill(ds )

'now add the foreign key constraint
Dim fk as ForeignKeyConst raint
fk = New ForeignKeyConst raint("FK_Custo mers_Orders", _
ds.Tables("Cust omers").Columns ("CustomerID "), _
ds.Tables("Orde rs").Columns("C ustomerID"))

Maybe if you play around with the code in this example,
you can figure out some way to get it to work. If you want
more help, you're going to need to post some code.

Robin S.
----------------
"max" <ma*@max.maxwro te in message
news:19***** ************@to rnado.fastwebne t.it...
>
Thanks for yor answer. I'm using VB2005, .Net 2.0.
Tables structure and data was developed in Access and loaded in a
dataset using the Data Source Configuration Wizard. Then I created
a form, dragged the table from the Dataset which creates a
bindingnavi gator obj on top of form; a second form load this form
by a button and I correctly see the data. There are only three
columns in the tables: an incremental ID (I gave it primary key),
a number, and a name. Then I need to change, insert and delete
records in the first table and replicate this change in all the
other four tables, that are identical in structure and data. I can
change and update data in the first table (because I see that
changes was really on it), but I cannot replicate in the others. I
have already tried to make relations using Data Designer, but it
doesn't work; I have read in some newsgroup that
ForeignKeyC onstraint cannot be created by this way.
I'd like to understand where and how insert vb code to create
relationshi p between columns in the first table to all the others.
I can't realize in which vb module, vb code must be added.
Thanks for your attention and sorry for my English.
Max
>
"RobinS" <Ro****@NoSpam. yah.noneha scritto nel messaggio
news:0e**** *************** ***********@com cast.com...
>>
>What kind of database are you using? VB2003 or VB2005?
>.Net 1.1 or .Net 2.0?
>>
>How are you filling your tables?
>>
>Robin S.
>-------------------------------------
>>
>"max" <ma*@max.maxwro te in message
>news:GY*** **************@ tornado.fastweb net.it...
>>>
>>Hello,
>>I am a newbye, and I'm trying to write a simple application.
>>I have five tables with three columns; all tables are identical;
>>I need to change some data in the first table and let VB updates
>>the same data in all other four tables in the right places.
>>I know it would be possible by using the ForeignKeyConst raint
>>object. I have created the tables using the DataSet Visual Tool
>>and I know it doesn't create any ForeignKeyConst raint obj. I
>>have found many codes examples on it, but I don't know how to
>>merge the code they in an existing dataset.
>>>
>>Hope somebody help.
>>Thanks in advance,
>>Max.
>>>
>>>
>>
>>
>>
>
>
>




"RobinS" <Ro****@NoSpam. yah.noneha scritto nel messaggio
news:AL******** *************** *******@comcast .com...
>Argh. Sorry; I didn't realize you were going to use my dataset
code. You need to use the OleDBDataAdapte r, not the SqlDataAdapter.
But you don't need that stuff if you're using a DataSet that
you set up in your DataSet designer; you only need the code defining
the Foreign Key Restraint. I included the other just to show
position.

I'm assuming you have *two* datatables in your dataset, one
being the parent and one being the child? Your code only
seems to fill one table. Where is the other one?

ds is my dataset name.
Customers is my parent table.
Orders is my child table.
CustomerID is the field in both tables that relates them
to each other.
>>>'now add the foreign key constraint
Dim fk as ForeignKeyConst raint
fk = New ForeignKeyConst raint("FK_Custo mers_Orders", _
ds.Tables("Cust omers").Columns ("CustomerID "), _
ds.Tables("Orde rs").Columns("C ustomerID"))

If you still can't figure it out, please re-post your code
showing the filling of the tables, probably in your form_load
routine.

And if you post more code, if you paste it into notepad and
then copy and paste it into your posting, it will be
indented properly and be easier to read.

Robin S.
-----------------------

"max" <ma*@max.maxwro te in message
news:9d******* ********@tornad o.fastwebnet.it ...
>>>
I'm sorry, but I really can't solve the problem.
I don't have any relationships defined in Access, neither I have set
in Dataset Designer.
Trying to use your code, I'm in trouble about connection string,
this is mine (I put the code in a Form_Load environment):
Provider=Micr osoft.Jet.OLEDB .4.0;Data Source="C:\xxx\ yyy.mdb"
I get an error in "Provider", it's not recognized by SqlDataAdapter.

I have this code:

Public Class Form_modPrest1
Private Sub TblPrest1Bindin gNavigatorSaveI tem_Click(ByVal sender As
System.Object , ByVal e As System.EventArg s) Handles
TblPrest1Bind ingNavigatorSav eItem.Click
Me.Validate ()
Me.TblPrest1B indingSource.En dEdit()
Me.TblPrest1T ableAdapter.Upd ate(Me.GestPres tDataSet.tblPre st1)
End Sub
Private Sub Form_modPrest1_ Load(ByVal sender As System.Object, ByVal
e As System.EventArg s) Handles MyBase.Load
Me.TblPrest1T ableAdapter.Fil l(Me.myDataSet. tblPrest1)

This cames automatically from dragging the tblPrest1 from dataset to
the form, in a datagrid format. I put your code under last line. And
it doesn't work.
Because I have other four tables identical to this, I get also five
forms identical, changing only the names of form (modPrest2...) and
names of tables (tblPrest2...)
Then I load these forms by a menu, and I see the contents of all
tables in datagrid format.
Then I make a change in the tblPrest1, and save the change by
clicking in the floppy disk icon. When I reload the table, changes
are effectively in use.
It seems this procedure already fill the table in dataset... or not?
I can't understand how automatically changing the other four tables
without calling each one by one.
I'm sorry for this but I'm really at the beginning about database
programming .
Please help and thanks for your patience.

"RobinS" <Ro****@NoSpam. yah.noneha scritto nel messaggio
news:p6****** *************** *********@comca st.com...
Do you have no relationships defined between the tables
in Access? Do they not show up in the Dataset Designer?

I'm not going to swear this will work. But you could
try adding your own foreign key constraints. I'm also not
sure where you would do this, but I would guess *after* the
dataset is filled, and *before* you do the binding. (I'm
assuming you're doing the binding in code, but maybe not?)

Here's an example on setting up a foreign key constraint.
This is from David Sceppa's book ADO.Net 2.0 The Core
Reference.

This uses the Customers and Orders tables from the Northwind
database.

'how to define a foreign key constraint
'first, fill your dataset with the two tables involved
'this is mine; this is loading from SQLServer, but
' load it however you're loading it from Access
Dim ss As String = "SELECT * FROM Customers; SELECT * FROM Orders"
Dim da As New SqlDataAdapter( ss, cs) 'cs is my connectionstrin g
da.TableMapp ings.Add("Table ","Customer s")
da.TableMapp ings.Add("Table 1","Orders")
Dim ds as New DataSet()
da.Fill(ds )

'now add the foreign key constraint
Dim fk as ForeignKeyConst raint
fk = New ForeignKeyConst raint("FK_Custo mers_Orders", _
ds.Tables("Cust omers").Columns ("CustomerID "), _
ds.Tables("Orde rs").Columns("C ustomerID"))

Maybe if you play around with the code in this example,
you can figure out some way to get it to work. If you want
more help, you're going to need to post some code.

Robin S.
----------------
"max" <ma*@max.maxwro te in message
news:19***** ************@to rnado.fastwebne t.it...
>
Thanks for yor answer. I'm using VB2005, .Net 2.0.
Tables structure and data was developed in Access and loaded in a
dataset using the Data Source Configuration Wizard. Then I created
a form, dragged the table from the Dataset which creates a
bindingnavi gator obj on top of form; a second form load this form
by a button and I correctly see the data. There are only three
columns in the tables: an incremental ID (I gave it primary key),
a number, and a name. Then I need to change, insert and delete
records in the first table and replicate this change in all the
other four tables, that are identical in structure and data. I can
change and update data in the first table (because I see that
changes was really on it), but I cannot replicate in the others. I
have already tried to make relations using Data Designer, but it
doesn't work; I have read in some newsgroup that
ForeignKeyC onstraint cannot be created by this way.
I'd like to understand where and how insert vb code to create
relationshi p between columns in the first table to all the others.
I can't realize in which vb module, vb code must be added.
Thanks for your attention and sorry for my English.
Max
>
"RobinS" <Ro****@NoSpam. yah.noneha scritto nel messaggio
news:0e**** *************** ***********@com cast.com...
>>
>What kind of database are you using? VB2003 or VB2005?
>.Net 1.1 or .Net 2.0?
>>
>How are you filling your tables?
>>
>Robin S.
>-------------------------------------
>>
>"max" <ma*@max.maxwro te in message
>news:GY*** **************@ tornado.fastweb net.it...
>>>
>>Hello,
>>I am a newbye, and I'm trying to write a simple application.
>>I have five tables with three columns; all tables are identical;
>>I need to change some data in the first table and let VB updates
>>the same data in all other four tables in the right places.
>>I know it would be possible by using the ForeignKeyConst raint
>>object. I have created the tables using the DataSet Visual Tool
>>and I know it doesn't create any ForeignKeyConst raint obj. I
>>have found many codes examples on it, but I don't know how to
>>merge the code they in an existing dataset.
>>>
>>Hope somebody help.
>>Thanks in advance,
>>Max.
>>>
>>>
>>
>>
>>
>
>
>




Dec 23 '06 #9
Max
I'm still trying Robin, but seems I cannot fill the second tabel after
implementing your code in my form_load. I see it after the console.writeli ne
routine. Data are present only in 'tblPrest1' tabel, while, moving mouse
around the console window, I see 'nothing' when I go to examinate tblPrest2'
table. In effect, the program skips the section regarding 'each
rowTblPrest2... ', because the value is 'nothing'. But I can't understand
why.
Anyway, I used the DataSet designer as the very first time to create
relationships, but it didn't work; I didn't get error messages, just no
change in 'tblPrest2'. Later, looking in newsgroup, I found somebody talking
about it's not possible to create it in this ** friendly ** way, but only by
writing code...
Thanks. I'll let you know.
PS: Are you looking at the newsgroup also in these 'holidays days'?

"RobinS" <Ro****@NoSpam. yah.noneha scritto nel messaggio
news:9L******** *************** *******@comcast .com...
>I forgot to tell you to add the constraint to the table definition.
Oops. Here's some code, with the line(s) I missed (look for the
asterisks).

Here's a working example. I set up a dataset for Northwind
with Customers and Orders and deleted the constraint that was
generated so I could create one in code. Customers corresponds
to your table1; Orders corresponds to your table2.

I didn't try modifying any of my data because I don't want to muck
up my data, but it should work. (famous last words)

----------
Dim ds As NorthwindDataSe t = New NorthwindDataSe t()
Dim custAdapter As CustomersTableA dapter = New CustomersTableA dapter()
custAdapter.Fil l(ds.Customers)
Dim orderAdapter As OrdersTableAdap ter = New OrdersTableAdap ter()
orderAdapter.Fi ll(ds.Orders)

Dim fk As ForeignKeyConst raint
fk = New ForeignKeyConst raint("FK_Custo mers_Orders", _
ds.Tables("Cust omers").Columns ("CustomerID "), _
ds.Tables("Orde rs").Columns("C ustomerID"))

'***THIS IS THE STEP I FORGOT TO INCLUDE -- Oops!
ds.Tables("Orde rs").Constraint s.Add(fk)
ds.EnforceConst raints = True

'Note: You can use the data relation created by the fk
' constraint to read through your data:

Dim rowCustomer As NorthwindDataSe t.CustomersRow
Dim rowOrder As NorthwindDataSe t.OrdersRow
Dim rel As DataRelation = ds.Relations("F K_Customers_Ord ers")
For Each rowCustomer In ds.Customers
Console.WriteLi ne("Orders for {0}", rowCustomer.Com panyName)
For Each rowOrder In rowCustomer.Get ChildRows(rel)
Console.WriteLi ne(" {0} - {1:d}", rowOrder.OrderI D,
rowOrder.OrderD ate)
Next rowOrder
Next rowCustomer

And here's something else I figured out: You *can* add the constraint
to your DataSet in the DataSet Designer.

To add a DataRelation, right-click on any item in the DataSet designer
(like in your table definition) and select Add and then Relation.

You can select the parent and child tables using the drop-down lists
at the top of the dialog box, and then the datacolumns just below
that.

The lower half of that dialog box lets you control whether the action
will create a DataRelation, a ForeignKeyConst raint, or both. The
default is just DataRelation, but you should choose ForeignKey or
Both. You can also specify values for the UpdateRule, DeleteRule,
and AcceptRejectCha ngesRule on the FK constraint. It defaults to
Cascade, Cascade, and None, which is fine.

If you have all of your tables in one DataSet that you created
through the DAtaSet designer, you can try adding the constraints
there. If you ever re-create the DataSet, you have to remember
to add the constraints, too, though.

Hope this helps.
Robin S.
-----------------------------------------------------------------
"Max" <no****@devnull .spamcop.netwro te in message
news:45******** **************@ news.tiscali.it ...
>Ok. I loaded in this form the secon table, too, and I fill it (I hope).
Then
nothing, the second table remians unchanged. I'm really getting crazy.
This is the code:

Public Class Form_modPrest1
Private Sub TblPrest1Bindin gNavigatorSaveI tem_Click(ByVal sender As
System.Objec t, ByVal e As System.EventArg s) Handles
TblPrest1Bindi ngNavigatorSave Item.Click
Me.Validate()
Me.TblPrest1Bin dingSource.EndE dit()
Me.TblPrest1Tab leAdapter.Updat e(Me.GestPrestD ataSet.tblPrest 1)
End Sub
Private Sub Form_modPrest1_ Load(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles MyBase.Load
Me.TblPrest2Tab leAdapter.Fill( Me.GestPrestDat aSet.tblPrest2)
'TODO: questa riga di codice carica i dati nella tabella
'GestPrestData Set.tblPrest1'. È possibile spostarla o rimuoverla se
necessario.
Me.TblPrest1Tab leAdapter.Fill( Me.GestPrestDat aSet.tblPrest1)
Dim fk As ForeignKeyConst raint
fk = New ForeignKeyConst raint("FK_tbl1_ tbl2", _
GestPrestDataSe t.Tables("tblPr est1").Columns( "NomePrest" ), _
GestPrestDataSe t.Tables("tblPr est2").Columns( "NomePrest" ))
End Sub
End Class

Thanks Robin

"RobinS" <Ro****@NoSpam. yah.noneha scritto nel messaggio
news:AL******* *************** ********@comcas t.com...
>>Argh. Sorry; I didn't realize you were going to use my dataset
code. You need to use the OleDBDataAdapte r, not the SqlDataAdapter.
But you don't need that stuff if you're using a DataSet that
you set up in your DataSet designer; you only need the code defining
the Foreign Key Restraint. I included the other just to show
position.

I'm assuming you have *two* datatables in your dataset, one
being the parent and one being the child? Your code only
seems to fill one table. Where is the other one?

ds is my dataset name.
Customers is my parent table.
Orders is my child table.
CustomerID is the field in both tables that relates them
to each other.

'now add the foreign key constraint
Dim fk as ForeignKeyConst raint
fk = New ForeignKeyConst raint("FK_Custo mers_Orders", _
ds.Tables("Cust omers").Columns ("CustomerID "), _
ds.Tables("Orde rs").Columns("C ustomerID"))

If you still can't figure it out, please re-post your code
showing the filling of the tables, probably in your form_load
routine.

And if you post more code, if you paste it into notepad and
then copy and paste it into your posting, it will be
indented properly and be easier to read.

Robin S.
-----------------------

"max" <ma*@max.maxwro te in message
news:9d****** *********@torna do.fastwebnet.i t...

I'm sorry, but I really can't solve the problem.
I don't have any relationships defined in Access, neither I have set in
Dataset Designer.
Trying to use your code, I'm in trouble about connection string, this
is mine (I put the code in a Form_Load environment):
Provider=Mic rosoft.Jet.OLED B.4.0;Data Source="C:\xxx\ yyy.mdb"
I get an error in "Provider", it's not recognized by SqlDataAdapter.

I have this code:

Public Class Form_modPrest1
Private Sub TblPrest1Bindin gNavigatorSaveI tem_Click(ByVal sender As
System.Objec t, ByVal e As System.EventArg s) Handles
TblPrest1Bin dingNavigatorSa veItem.Click
Me.Validate( )
Me.TblPrest1 BindingSource.E ndEdit()
Me.TblPrest1 TableAdapter.Up date(Me.GestPre stDataSet.tblPr est1)
End Sub
Private Sub Form_modPrest1_ Load(ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles MyBase.Load
Me.TblPrest1 TableAdapter.Fi ll(Me.myDataSet .tblPrest1)

This cames automatically from dragging the tblPrest1 from dataset to
the form, in a datagrid format. I put your code under last line. And it
doesn't work.
Because I have other four tables identical to this, I get also five
forms identical, changing only the names of form (modPrest2...) and
names of tables (tblPrest2...)
Then I load these forms by a menu, and I see the contents of all tables
in datagrid format.
Then I make a change in the tblPrest1, and save the change by clicking
in the floppy disk icon. When I reload the table, changes are
effectivel y in use.
It seems this procedure already fill the table in dataset... or not?
I can't understand how automatically changing the other four tables
without calling each one by one.
I'm sorry for this but I'm really at the beginning about database
programmin g.
Please help and thanks for your patience.

"RobinS" <Ro****@NoSpam. yah.noneha scritto nel messaggio
news:p6***** *************** **********@comc ast.com...
>
>
Do you have no relationships defined between the tables
in Access? Do they not show up in the Dataset Designer?
>
I'm not going to swear this will work. But you could
try adding your own foreign key constraints. I'm also not
sure where you would do this, but I would guess *after* the
dataset is filled, and *before* you do the binding. (I'm
assuming you're doing the binding in code, but maybe not?)
>
Here's an example on setting up a foreign key constraint.
This is from David Sceppa's book ADO.Net 2.0 The Core
Reference .
>
This uses the Customers and Orders tables from the Northwind
database.
>
'how to define a foreign key constraint
'first, fill your dataset with the two tables involved
'this is mine; this is loading from SQLServer, but
' load it however you're loading it from Access
Dim ss As String = "SELECT * FROM Customers; SELECT * FROM Orders"
Dim da As New SqlDataAdapter( ss, cs) 'cs is my connectionstrin g
da.TableMap pings.Add("Tabl e","Customer s")
da.TableMap pings.Add("Tabl e1","Orders")
Dim ds as New DataSet()
da.Fill(d s)
>
'now add the foreign key constraint
Dim fk as ForeignKeyConst raint
fk = New ForeignKeyConst raint("FK_Custo mers_Orders", _
ds.Tables("Cust omers").Columns ("CustomerID "), _
ds.Tables("Orde rs").Columns("C ustomerID"))
>
Maybe if you play around with the code in this example,
you can figure out some way to get it to work. If you want
more help, you're going to need to post some code.
>
Robin S.

Dec 24 '06 #10

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

Similar topics

4
4402
by: I_AM_DON_AND_YOU? | last post by:
There is one more problem I am facing but didn't get the solution. In my Setup Program I am not been able to create 2 things (when the program is intalled on the client machine ) : (1) create shortcut to my program/utility (2) Entry in Windows' Start --> Program Menu. Actually in my VB.Net solution I have two projects (1) MYPROGRAM (2)...
1
2119
by: Agnes | last post by:
Please be kind to take a look dsSeaInvInfo.Clear() daSeaInvInfo.SelectCommand = New SqlCommand daSeaInvInfo.SelectCommand.Connection = conSea daSeaInvInfo.TableMappings.Add("Table", "invoiceheader") daSeaInvInfo.SelectCommand.CommandText = "select * from invoiceheader" daSeaInvInfo.Fill(dsSeaInvInfo, "invoiceheader")...
1
2646
by: jaYPee | last post by:
I have created 3 sqldataadapter. each adapter.selectcommand has a parameter. I have added a textbox to supply a value for each parameter. My problem is when I press enter the second time to fire up the keypress event from the textbox I recieved this error in datagrid object "ForeignKeyConstraint StudentsSchYrSem requires the child key values...
1
1697
by: David A. Osborn | last post by:
I keep getting the following message when adding a new record to a database that has two tables. On table is a parent to the other. I am adding a new parent record that has child records and I get the following: ForeignKeyConstraint drtblCDstblSongs requires the child key value(9) to exist in the parent table. Do you want to correct the...
13
10116
by: dbuchanan | last post by:
Hello, Here is the error message; ---------------------------- Exception Message: ForeignKeyConstraint Lkp_tbl040Cmpt_lkp302SensorType requires the child key values (5) to exist in the parent table. ----------------------------
18
2699
by: Steven Bethard | last post by:
I've updated the PEP based on a number of comments on comp.lang.python. The most updated versions are still at: http://ucsu.colorado.edu/~bethard/py/pep_create_statement.txt http://ucsu.colorado.edu/~bethard/py/pep_create_statement.html In this post, I'm especially soliciting review of Carl Banks's point (now discussed under Open Issues)...
0
7876
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...
0
7804
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...
0
8156
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. ...
1
5681
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...
0
3809
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...
0
3832
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2307
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
1
1409
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1144
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...

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.