So here is my code
This is suppose to insert information into the donor_history table and then insert information into the ticket table, where hist_id is suppose to repeate itself over and over until the transaction is finished.
So if a person buys 5 tickets, ticket_id 1-5 would have the hist_id of 1.
I believe I do this through a select @@idenity. My insert query looks like this.
then my loop starts for the ticket insert query
is this right? My ticket table keeps getting a hist_id value of 1. I'm at a loss right now.
VB.NET:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim daPrice As RMDHDataSet.Ticket_PriceDataTable
Dim quant As Integer
Dim price As Double
Dim i As Integer
Dim price_id As Integer
'Dim History_Id As Integer
Dim donor_id As Integer
Dim ticket_status_id As Integer
Dim history_date As Date
Dim Employee_ID As Integer
Dim Payment_ID As Double
Dim Total As Integer
Dim Credit_Card As String
Dim Security As String
Dim Experation As String
Dim Name_On_Card As String
Dim hist_id As Integer
Payment_ID = 1
Employee_ID = 1
history_date = Format(Now, "Short Date")
ticket_status_id = 1
donor_id = 1
quant = txtquanity.Text
daPrice = Ticket_PriceTableAdapter.GetDataBy(quant)
price = Double.Parse(daPrice.Rows(0).Item("Ticket_Price"))
price_id = Integer.Parse(daPrice.Rows(0).Item("Ticket_Price_ID"))
txtCostPerTicket.Text = price
txtTicketTotal.Text = price * quant
Total = txtTicketTotal.Text
Credit_Card = txtCreditCard.Text
Security = txtSecurity.Text
Experation = txtExperation.Text
Name_On_Card = txtNameOnCard.Text
Donor_HistoryTableAdapter.InsertQuery(donor_id, history_date, Total, quant, price_id, Employee_ID, Payment_ID)
hist_id = txthist_id.Text
For i = 1 To quant
TicketsTableAdapter.InsertQuery(hist_id, txtSalesGiftType.Text, price_id, ticket_status_id, donor_id)
Next
This is suppose to insert information into the donor_history table and then insert information into the ticket table, where hist_id is suppose to repeate itself over and over until the transaction is finished.
So if a person buys 5 tickets, ticket_id 1-5 would have the hist_id of 1.
I believe I do this through a select @@idenity. My insert query looks like this.
VB.NET:
INSERT INTO Donor_History
(Donor_ID, Hist_Date, Ticket_Amount, Ticket_Count, Ticket_Price_ID, Employee_ID, Payment_Type_ID)
VALUES (@Donor_ID,@Hist_Date,@Ticket_Amount,@Ticket_Count,@Ticket_Price_ID,@Employee_ID,@Payment_Type_ID);
SELECT Hist_ID, Donor_ID, Hist_Date, Marketing_Promo_ID, Ticket_Amount, Ticket_Count, Ticket_Price_ID, Employee_ID, Payment_Type_ID,
Credit_Card_Number, Credit_Card_Security, Credit_Card_Experation, Name_On_Card, scan_image FROM Donor_History WHERE (Hist_ID = SCOPE_IDENTITY());
SELECT @@identity;
then my loop starts for the ticket insert query
VB.NET:
INSERT INTO Tickets
(Hist_ID, Gift_Type, Ticket_Price_ID, Ticket_Status_ID, Donor_ID)
VALUES (@Hist_ID, @Gift_Type,@Ticket_Price_ID,@Ticket_Status_ID,@Donor_ID);
SELECT Ticket_ID, hist_id, Gift_Type, Ticket_Price_ID, Ticket_Status_ID, Donor_ID FROM Tickets WHERE (Ticket_ID = SCOPE_IDENTITY())
is this right? My ticket table keeps getting a hist_id value of 1. I'm at a loss right now.
Last edited by a moderator: