Showing posts with label child. Show all posts
Showing posts with label child. Show all posts

Wednesday, March 28, 2012

Need help / suggestion

Hey guys

I have to implement a dynamic Parent - > Child Scenario ... but the catch is
as Follows :

I need to create this Table Design so that I can have multiple Parent ->
child - > parent Relationships

(ie Db driven "Window Explorer - feel". 1 Folder that holds another Folder
that holds another Folder etc to Infinite )

So if the Above makes any sense ... Suggestions would be Welcome

Thanx1) Get a copy of TREES & HIERARCHIES IN SQL for several different
methods

2) Google for "nested sets", "path enumeration" and "adjacency list"
models in SQL|||Thanx !!!

"--CELKO--" <jcelko212@.earthlink.net> wrote in message
news:1109335451.349754.115330@.l41g2000cwc.googlegr oups.com...
> 1) Get a copy of TREES & HIERARCHIES IN SQL for several different
> methods
> 2) Google for "nested sets", "path enumeration" and "adjacency list"
> models in SQL|||Nice 1 celko !!! :P
http://www.intelligententerprise.co...equestid=315563

"--CELKO--" <jcelko212@.earthlink.net> wrote in message
news:1109335451.349754.115330@.l41g2000cwc.googlegr oups.com...
> 1) Get a copy of TREES & HIERARCHIES IN SQL for several different
> methods
> 2) Google for "nested sets", "path enumeration" and "adjacency list"
> models in SQL

Wednesday, March 21, 2012

Need child TABLE object to ref diff DATASET than parent LIST object.

Dang, I wish I had figured this out without having to ask.
Looked and looked for a similar thread - but no real "keyword" for
this issue.
Here's the situation; imagine you have customers and one database
table has demographic information while another database table has a
list of customer orders. Now you want a report that shows all that on
a document map-driven report.
Here's the page layout:
LIST OBJECT // DATASET(dsDemographics) GROUPBY(customer)
DOCMAP(customer)
>> TABLE OBJECT DATASET(dsDemographics) GROUPBY()
>> TABLE OBJECT DATASET(dsOrders) GROUPBY(orderdate)
>> TABLE OBJECT DATASET(dsTickets) GROUPBY(createdate)
Here's the problem: the second table containing orders will not
reference the dsOrders DATASET unless through aggregations - which is
obviously not what I am wanting to do. I want to list all the orders
for the current customer. Same problem with the third table - and
others.
Now, I see the problem is very clear. The orders DATASET does not know
how to filter itself on the current customer. That much I understand.
How do I do it?
Thanks in advance, JerrySounds like your needing to join the datasets. Easiest way would be to join
the data prior to pulling it into RS because, as you noted, RS can only join
data from one dataset to another using an aggregate. If one of your
datasets is SQL, you might use a linked server to pre-join your data.
--
-- "This posting is provided 'AS IS' with no warranties, and confers no
rights."
jhmiller@.online.microsoft.com
"Jerry Nixon" <jerrynixon@.gmail.com> wrote in message
news:36f558cf.0410221151.4074f9f8@.posting.google.com...
> Dang, I wish I had figured this out without having to ask.
> Looked and looked for a similar thread - but no real "keyword" for
> this issue.
> Here's the situation; imagine you have customers and one database
> table has demographic information while another database table has a
> list of customer orders. Now you want a report that shows all that on
> a document map-driven report.
> Here's the page layout:
> LIST OBJECT // DATASET(dsDemographics) GROUPBY(customer)
> DOCMAP(customer)
>> TABLE OBJECT DATASET(dsDemographics) GROUPBY()
>> TABLE OBJECT DATASET(dsOrders) GROUPBY(orderdate)
>> TABLE OBJECT DATASET(dsTickets) GROUPBY(createdate)
> Here's the problem: the second table containing orders will not
> reference the dsOrders DATASET unless through aggregations - which is
> obviously not what I am wanting to do. I want to list all the orders
> for the current customer. Same problem with the third table - and
> others.
> Now, I see the problem is very clear. The orders DATASET does not know
> how to filter itself on the current customer. That much I understand.
> How do I do it?
> Thanks in advance, Jerry

Friday, March 9, 2012

Need advice for Parent Child simultaneusly insert by many user


Need advice for Parent Child insert in transaction mode
I have Parent child table as decribe below:
Parent Table name = TESTPARENT
1. counter bigint isIdentity=Yes Increment=1 Seed=1
2. customer nChar(10)
Child Table name = TESTCHILD
1. counter bigint
2. qty numeric(3,0)
I want to insert new record with code below:
void button1_Click(object sender, EventArgs e)
{
// Define object to catch @.@.indentity
object myCounter;
// Connect to database & open
myConnection = new SqlConnection("Data Source=SQL2005;Initial
Catalog=XXX;User ID=sa; Password=YYY");
myConnection.Open();
// define transaction
SqlTransaction myAtom = myConnection.BeginTransaction();
SqlCommand myAtomCmd = myConnection.CreateCommand();
myAtomCmd.Transaction = myAtom;
// Start insert to database with transaction mode
try
{
// Insert parent new record
myAtomCmd.CommandText = string.Format("insert into TESTPARENT (customer)
values ('{0}')", tbCustomer.Text);
myAtomCmd.ExecuteNonQuery();
// Get Indentity
myAtomCmd.CommandText = "SELECT @.@.identity from testParent";
myCounter = myAtomCmd.ExecuteScalar();
// insert child new record
myAtomCmd.CommandText = string.Format("insert into TESTCHILD (counter,
qty) values ('{0}', {1})", Convert.ToInt64(myCounter.ToString()),
tbQty.Value);
myAtomCmd.ExecuteNonQuery();
// Commit transaction
myAtom.Commit();
}
catch
{
myAtom.Rollback();
MessageBox.Show("Data not inserted");
}
}
I already try with 2 workstation and 1 server, that code working well
(not duplicate in parent and insert right relation child parent record
in child table ).
I am not sure that code will stay stable when the table inserted
simultaneusly by many user.
Please advice, that code is the right way.
*** Sent via Developersdex http://www.examnotes.net ***The DBA side of me is cringing, becuae you're not using stored
procedures to insert data into a database; you really should use a
stored procedure when running against SQL Server. I realize that there
may be reasons to not use a stored procedure, but thos should be the
exception, and not the rule. Oh, and if you're going to use IDENTITY
columns, you should probably be using SCOPE_IDENTITY, and not
@.@.IDENTITY to return the last value inserted.
The developer side of me (recognizing that this might be one of those
rare times when a stored procedure is not appropriate) is cringing
because you are not using parameters to issue commands to your
database, thereby opening yourself up to SQL injection. You are also
connecting to your database as "sa", which means that if someone
figures out your connection string, they own your server.
Try replacing the value of tbCustomer.Text with "1'); DROP TABLE
TestParent--" and see what happens.
You need to make the following changes:
1. Don't connect to a database using sa; create a user with the
appropriate permissions.
2. Use a stored procedure for all CRUD operations (if you don't know
what CRUD stands for, Google it; it'll help you understand a lot more
that this single post will explain).
3. If you can't use a stored procedure (vendor issue, server doesn't
support stored procedures, etc), then use parameters on your client
side; don't build strings.
HTH,
Stu