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.
Author |
Topic |
programer
Posting Yak Master
221 Posts |
Posted - 2010-08-02 : 16:18:38
|
How to save the 4 lines at the same timeExample:I have a table:tbl_Payment:UserIdPaymentIdPaymentTypetbl_PaymentDetails:UserIdPaymentIdAttributeNameValue1st table:UserId, PaymentId, PaymentType1 1 Visa2 2 MasterCard3 3 Paypal, etc. ..4 45 56 62nd table:UserId, PaymentId, AttributeName, Value1 1 Credit number 432432432432422 1 he intended fsdfsdfsdfsdfsd Credit3 1 etc ...4 3 paypal email5It can be done to save 4 lines at once?In VS I have:Payment optionCredit card numbetCredit on meetc ...I would immediately save the 4 lines in column AttributeName. |
|
X002548
Not Just a Number
15586 Posts |
|
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 noThis 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();Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam
|
|
|
|
|
|
|
|