473,792 Members | 2,937 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

inputting information when there is a foreign key

7 New Member
Hi all,


In Ms Access, I have a Customer table and a Credit Card table. The CustomerID field is a primary key in the Credit Card table. Both tables already have sample data in it.

So, when a customer wants to purchase a product, they proceed to checkout and payment. They fill out the payment form where their credit card information is inputted.

When the customer submits the form , the system checks to see if the information is already in the database. If it is, the user is directed to the Payment Approved page. However, if the information is not already in the Credit Card table then it has to be inputted.

The customer would already have a customerid when they register. The customerid in the customer table is an autonumber. the one in the credit card table is a number datatype.

I am trying to put the information in the database using the code below but nothing is going in. It goes directly to the Payment Approved page.


Expand|Select|Wrap|Line Numbers
  1. Protected Sub BTNProcess_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles BTNProcess.Click
  2.  
  3. Dim myShoppingCart As ShoppingCart
  4.  
  5. myShoppingCart = DirectCast(Session("ShoppingCart"), ShoppingCart)
  6.  
  7. Dim no As String
  8.  
  9. no = Me.TextBox2.Text.Trim()
  10.  
  11. Dim connectionstring As String
  12. connectionstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath("GameDB.mdb")
  13.  
  14. Using connection As New OleDbConnection(connectionstring)
  15. connection.Open()
  16.  
  17. Dim cmdText As String = "SELECT * FROM CreditCard;"
  18. Dim command As OleDbCommand
  19. command = New OleDbCommand(cmdText, connection)
  20. Dim reader As OleDbDataReader
  21. reader = command.ExecuteReader
  22.  
  23. If reader.HasRows Then
  24. Response.Redirect("PaymentApproved.aspx")
  25.  
  26. Return
  27.  
  28. Else
  29.  
  30. Dim cn As String = TextBox2.Text
  31. Dim em As String = DDLMonth.Text
  32. Dim ey As String = DDLYear.Text
  33. Dim fn As String = TextBox1.Text
  34. Dim ln As String = TextBox4.Text
  35. Dim ba As String = TextBox5.Text
  36. Dim autonumber As Integer
  37.  
  38. Dim check As Integer
  39. check = Microsoft.VisualBasic.Val("CCID")
  40.  
  41.  If check < Microsoft.VisualBasic.Val("CCID") Then
  42.  
  43. autonumber = check
  44.  
  45.  End If
  46.  
  47. Dim CID As String
  48.  
  49. Session("SessionUser") = ("CustomerID").ToString
  50.  
  51. CID = Session("SessionUser")
  52.  
  53. cmdText = "INSERT INTO CreditCard (CCNumber, CustomerID, CCExpireMonth, CCExpireYear, CCFirstName, CCLastName, BillingAddress) VALUES ('" + cn + "','" + CID + "','" + em + "','" + ey + "','" + fn + "','" + ln + "','" + ba + "')"
  54.  
  55. command = New OleDbCommand(cmdText, connection)
  56. command.ExecuteNonQuery()
  57. Response.Redirect("PaymentApproved.aspx")
  58.  
  59.  End If
  60.  
  61.  End Using
  62.  
  63.  End Sub


I think it is the foreign key that is giving the problem because the foreign key has to be the customerid. So how do I get that from the session user. Or it might be something else that is the problem.


Can anyone help me?
Aug 7 '08 #1
0 944

Sign in to post your reply or Sign up for a free account.

Similar topics

0
2636
by: Jeremiah Jacks | last post by:
I just upgraded to MySQL 4.0.14-standard for RedHat Linux and am using = the pre-compiled binaries. I have a database with INNODB tables. When I insert a row into one of the child tables, I get the following = MySQL error: INSERT INTO product_access_level (product_id,access_level_id) VALUES
13
1920
by: Immanuel Goldstein | last post by:
Obtained under the Freedom of Information Act by the National Security Archive at George Washington University and posted on the Web today, the 74-page "Information Operations Roadmap" admits that "information intended for foreign audiences, including public diplomacy and PSYOP, increasingly is consumed by our domestic audience and vice-versa," but argues that "the distinction between foreign and domestic audiences becomes more a question...
11
2035
by: Nemisis | last post by:
Hi everyone, sorry if this post gets really long, i just wanna make sure i fully explain what i am trying to do. I am new to OOP and .net 2.0, so if this is obvious, i am sorry. I have wrote a data access layer, which contists of separate servicebases for each object within my database. CompanyDataService (contains CRUD methods) ContactDataService (contains CRUD methods)
22
2741
by: Sandman | last post by:
So, I have this content management system I've developed myself. The system has a solid community part where members can register and then participate in forums, write weblogs and a ton of other things. So, in instances where I list, for example, the latest weblogs. I list the headline of the weblog, the date and the name of the member who wrote it. Now, the name isn't just "Smith", but rather Smith's online status, his nick and his...
1
2493
by: mdk7 | last post by:
I am very new to developing forms and queries with Access. The task that I am required to complete is as follows: Build a form based user interface that displays various information from the underlining tables as well as allow for updating of this information. The problem I am having is that all the information that needs to be displaced needs to ‘created’ using a query ie: the form displays information from multiple sets of tables and...
2
1730
by: UofFprogrammer | last post by:
Hello, Several Weeks ago I asked a question about testing for the end of an input file. I have been using this method pretty well for inputting information from an external file. I am using C++. char line; while(file>>line){ Where line is a c-string and file is an input stream. But this only reads until the first space it encounters. I now want to try to take in an entire line, regardless of what it contains (such as whitespace) as a...
1
1435
by: TaylorLeonard | last post by:
Hi, I have been trying to figure this out for hours, but can't seem to get it. I have a form where the administrator inputs someone elses personal info (FirstName, lastName, email, phone#, etc.) and when they click enter, I have it so a new entry is created in my Volunteer table. What i would like to do it, is when the admin clicks the enter button, a new entry will be made in the Password table. When a new record is added to the Volunteer...
16
2025
by: HypeBeast McStreetwear | last post by:
Hey Guys I have to make a program where it accepts/denies applications into a club. The program should read in information about applicants (None was given so I believe I have to make up some applicant info in Notepad) and output a statement of acceptance or rejection for each applicant. Each input line contains the follwing information about the applicant: Applicant's ID number (0-9,999) Age (0-120) Score on the Test of Social...
0
1494
by: nustapha | last post by:
Hi, I can see foreign keys in the information schema db in mysql but there is no information about 'on delete cascade' or 'on update...'. How can I get all information about foreign keys?
0
10211
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9033
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3719
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2917
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.