CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > visual_studio.visual_studio_2005 Tags:
Item Type: NewsGroup Date Entered: 2/10/2006 8:30:49 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 4 Views: 33 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
5 Items, 1 Pages 1 |< << Go >> >|
dliebich
Asp.Net User
How to make VS create Insert statement on normalized tables (multiple tables)2/10/2006 8:30:49 PM

0/0

Here is a tought one, I hope someone can help me. I know VS is able to create inserts, update,..., for a single table but how can I create those for multiple tables when I normalized my model. I cannot believe I'm forced to do it all by myself?

Here is hat I have:

tbl_Collection
- ID (PK)
- description
- ... 

tbl_Base
- ID (PK)
- CollectionID (FK)
- ownerID
- ....

tbl_BaseDetail
- ID (PK)
- BaseID (FK)
- value
- ...

There is a 1:n relationship between Collection : Basis and a 1:n relation between Base : BaseDetail

I have a CSV file that holds multiple number series which I like to store into my DB. every CSV file is treated like a collection, every single line is put into base and basedetail.

So what I like to do is to read the file line by line and run an insert. As of now I couldn't figure out how to make VS help me with the creation of the statement. I know I have to get the identity back per higher level to insert below e.g. Collection, Base, BaseDetail. Therefore a single insert is a bit more complicated. Also ideally I would like stored procedure calls.

Please I don't want to use DTS or the newer stuff as I like to implement a class that also allows me to update and delete the data.

Can somebody please explain to me how VS would provide what I need or in case VS won't do it explain to me how I have to do it.

Thanks in advance.

Dirk

pkellner
Asp.Net User
Re: How to make VS create Insert statement on normalized tables (multiple tables)2/11/2006 6:24:38 AM

0/0

I'd suggest creating an ObjectDataSource.  Inside the insert method you can do whatever you want.  I just recently completed an ODS that is used for membership that automatically updates both the Membership tables as well as a second table foreign key'd into membership.  I think that is similar.

 


Peter Kellner
http://73rdstreet.com and blogging at
http://PeterKellner.net
MVP, ASP.NET
dliebich
Asp.Net User
Re: How to make VS create Insert statement on normalized tables (multiple tables)2/11/2006 2:18:48 PM

0/0

does ODS create the staged insert for me or do I have to iterate through? would you mind to share more detail as to how to go about this task, that would be great!

dirk

pkellner
Asp.Net User
Re: How to make VS create Insert statement on normalized tables (multiple tables)2/11/2006 4:00:41 PM

0/0

ODS lets you build your own method that does the staged insert.  I'll post here some pseudo code of what it might look like:

 public void InsertAlldbo_CustomerInfo(Guid userkey, string firstname, string lastname, string billingaddress, string city, string state, , string gender, DateTime birthdate, Double height, int planname_id)
        {
            SqlConnection connection = new SqlConnection(connectionString);
            String insertString = "INSERT INTO dbo.CustomerInfo (";
            insertString += "UserKey";
            insertString += ",FirstName";
            insertString += ",LastName";
                   insertString += ",BirthDate";
            insertString += ",Height";
            insertString += ",PlanName_id";
            insertString += ") VALUES (";
            insertString += "@userkey";
            insertString += ",@firstname";
            insertString += ",@lastname";
             insertString += ",@height";
            insertString += ",@planname_id";
            insertString += "); ";
            SqlCommand cmd = new SqlCommand(insertString, connection);
            cmd.Parameters.Add("@userkey", SqlDbType.UniqueIdentifier, 16).Value = userkey;
            cmd.Parameters.Add("@firstname", SqlDbType.VarChar, 50).Value = firstname == null ? String.Empty : firstname;
            cmd.Parameters.Add("@lastname", SqlDbType.VarChar, 50).Value = lastname == null ? String.Empty : lastname;
                  cmd.Parameters.Add("@height", SqlDbType.Float, 17).Value = height;
            cmd.Parameters.Add("@planname_id", SqlDbType.Int, 0).Value = planname_id;
            try
            {
                connection.Open();
                cmd.ExecuteNonQuery();
            }
            catch (SqlException err)
            {
                throw new ApplicationException("TestODS Insert Error." + err.ToString());
            }
            finally
            {
                connection.Close();
             }

        AND DO SOME MORE INESRT STUFF INTO ANOTHE RTABLE..


        }


Peter Kellner
http://73rdstreet.com and blogging at
http://PeterKellner.net
MVP, ASP.NET
farooq789
Asp.Net User
Re: How to make VS create Insert statement on normalized tables (multiple tables)10/26/2007 12:31:33 PM

0/0

I refered to the above code and my requirement is

I have 3 checkboxes  in aspx page,  I m using check boxes with  labels for displaing checkboxes values and if user select one check out of 3 then selected check box value from corresponding  label value  to be store in the database

how can I modify this code for I have checkboxes

 

String insertString = "INSERT INTO dbo.CustomerInfo (";
            insertString += "UserKey";
            insertString += ",FirstName";
            insertString += ",LastName";
                   insertString += ",BirthDate";
            insertString += ",Height";
            insertString += ",PlanName_id";
            insertString += ") VALUES (";
            insertString += "@userkey";
            insertString += ",@firstname";
            insertString += ",@lastname";
             insertString += ",@height";
            insertString += ",@planname_id";
            insertString += "); ";

 

Need help

thanks

[email protected]

 

5 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Java Oracle Database Development Authors: David Gallardo, Pages: 420, Published: 2003
Pro Visual Studio 2005 Team System Application Development: Application Design Authors: Steve Shrimpton, Pages: 768, Published: 2006
Java Programming 10-Minute Solutions: 10-minute Solutions Authors: Mark Watson, Pages: 332, Published: 2004
Sams Teach Yourself Mysql in 10 Minutes Authors: Chris Newman, Pages: 277, Published: 2006
Professional Oracle Programming Authors: Rick Greenwald, Robert Stackowiak, Gary Dodge, David Klein, Ben Shapiro, Christopher G. Chelliah, Pages: 758, Published: 2005
F. Scott Barker's Access 2002 Power Programming Authors: F. Scott Barker, Pages: 960, Published: 2001
Beginning SQL Server 2005 Programming Authors: Robert Vieira, Pages: 688, Published: 2006
Mastering SQL Server 2000 Authors: Mike Gunderloy, Joseph L. Jorden, Joe Jorden, Pages: 1201, Published: 2000
Beginning Databases with PostgreSQL: From Novice to Professional, Second Edition: From Novice to Professional Authors: Neil Matthew, Richard Stones, Pages: 637, Published: 2005

Web:
Re: Querying multiple tables Aug 1, 2007 ... Be explicit when naming columns in an INSERT statement. .... From: Paul Malherbe . References:. Querying multiple tables. From: Paul Malherbe ...
Create table and insert data by sql query in javabeans,Create ... Statistical summary of data in a given tables. CREATE... to the data modification statement like INSERT and UPDATE statements to fulfill...; The CREATE VIEW ...
SQL SERVER - Insert Multiple Records Using One Insert Statement ... Is it possible to insert different values in multiple tables ...... You write a method to make a statement that inserts all the records at once (using your ...
Inserting Data into multiple tables in Oracle Database by pressing ... Normalize your database. In other words establish the foreign key and ... Is thr any better way to insert data into multiple tables from one ...
Performance problems inserting and querying large tables data for each trace statement was flattened out so that it resulted into a single insert into a table as opposed to a hierarchy of multiple tables. For ...
Database normalization - Wikipedia, the free encyclopedia Higher degrees of normalization typically involve more tables and create the .... by joining multiple tables each having a subset of the attributes of T. ...
Implementing Table Inheritance in SQL Server - SQLTeam.com Feb 20, 2008 ... Yet, we must separate them into multiple tables because we need to .... State 0, Line 1 The INSERT statement conflicted with the FOREIGN KEY ...
oracle insert,oracle update,oracle update set,oracle update sql ... The INSERT statement enables you to enter data into the database. ... Lookup tables can contain data that is spread out across multiple tables in multiple ...
SQL Best Practices « Paul Sweatte Make sure columns selected from multiple tables are dereferenced by a bind variable ... Make sure to qualify all INSERT and UPDATE statements with a SELECT ...
mysql insert into multiple tables at once? how do I write a mysql query to insert into multiple tables at once? ... attempt to join tables (use more than one in the same sql statement) they cannot be ...




Search This Site:










expandable tableitemstyle in designer

binding dataset to gridview in wpf

error changing the master page specified on content page

c# -- auto-generate email with verification link

very good vwd tutorial for those who are new to vwd and asp.net

how to execute multiple projects on a single a solution

converting vb.net webapplication to vwd

skins for dnn 3.2.1

private assembly installer - specifying upload directory in .dnn install file

is this of use to anyone?

two forms authentications:

enterprise library daab

windows 2003 iis 6.0 & aspnet user account problems

migrate site to different hardware

no design while on runtime...

how create several different profile?

displaying a web page inside a tab page...???

question about creating menus

3.0.12 usersonline and unauthorized users

keep a treeview's state?

scroll bar in left panel of masterpage

system.security.securityexception

vwd express - could not find schema information for the attribute/element

object reference not set to an instance of an object.

accessing a control within a loginview

solpart menu spacing

duh! - i know the answer is here but cannot find it

rsa key container - permission granting error

title text of controls inside a webpart

adding profile data at time of user creation.

 
All Times Are GMT