Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 .NET Inside SQL Server (2005)
 How to save the 4 lines at the same time

Author  Topic 

programer
Posting Yak Master

221 Posts

Posted - 2010-08-02 : 16:18:38
How to save the 4 lines at the same time

Example:

I have a table:

tbl_Payment:
UserId
PaymentId
PaymentType


tbl_PaymentDetails:
UserId
PaymentId
AttributeName
Value

1st table:
UserId, PaymentId, PaymentType
1 1 Visa
2 2 MasterCard
3 3 Paypal, etc. ..
4 4
5 5
6 6



2nd table:
UserId, PaymentId, AttributeName, Value
1 1 Credit number 43243243243242
2 1 he intended fsdfsdfsdfsdfsd Credit
3 1 etc ...
4 3 paypal email
5



It can be done to save 4 lines at once?

In VS I have:

Payment option

Credit card numbet

Credit on me

etc ...


I would immediately save the 4 lines in column AttributeName.

X002548
Not Just a Number

15586 Posts

Posted - 2010-08-02 : 16:55:15
ou want to Insert 4 rows of data to 1 table in 1 SQL step?

Is that what you're asking?

The answer is, perhaps...

Where is the data coming from?

If you're asking to insert data into 2 tables at the same time?

The answer in no



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

programer
Posting Yak Master

221 Posts

Posted - 2010-08-02 : 17:28:41
quote:
Originally posted by X002548

ou want to Insert 4 rows of data to 1 table in 1 SQL step?

Is that what you're asking?

The answer is, perhaps...

Where is the data coming from?

If you're asking to insert data into 2 tables at the same time?

The answer in no



This means I have to write a function in VS:

var TestRecords = new[] {
new { UserID = UserID,
CardId = DropDownList4.Text+CreditCardNumber.Text,
Attribute = "Credit card type",
Value = DropDownList4.Text },
new { UserID = UserID,
CardId = DropDownList4.Text+CreditCardNumber.Text,
Attribute = "Credit card number",
Value = CreditCardNumberEncrypt + UserID },
new { UserID = UserID,
CardId = DropDownList4.Text+CreditCardNumber.Text,
Attribute = "Name on card",
Value = NameOnCardEncrypt },
new { UserID = UserID,
CardId = DropDownList4.Text+CreditCardNumber.Text,
Attribute = "Expiry Date",
Value = MM.Text +"/" + yearEnd }};
foreach (var item in TestRecords)
{
SqlDataSource1.InsertParameters["UserID"].DefaultValue = item.UserID;
SqlDataSource1.InsertParameters["CardId"].DefaultValue = item.CardId;
SqlDataSource1.InsertParameters["AttributeName"].DefaultValue = item.Attribute;
SqlDataSource1.InsertParameters["Value"].DefaultValue = item.Value;
SqlDataSource1.Insert();





Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam





Go to Top of Page
   

- Advertisement -