What is the correct syntax?

Results 1 to 2 of 2

Thread: What is the correct syntax?

  1. #1
    Join Date
    Dec 1969

    Default What is the correct syntax?

    Hi all. An example would best illustrate my problem. I need to insert form values into a database table On the form, the user selects a person. This person needs to be inserted into the Int_P table. The required values in this table are int_ID (primary key), and per_id (foreign key). The value of per_id is taken from the PER table. What I&#039m not sure how to do is to get the value of per_id from the PER table and associate it with the row that is being inserted. Here&#039s what I have so far, I seriously doubt that the syntax is correct, and I would appreciate any help!<BR><BR>"insert into int_p (int_id, per_id, int_per_name) VALUES(&#039"& session("lngIntID") & "&#039, (SELECT per_id from PER where per_name=&#039"& Request.Form("IntPerName") & "&#039), &#039"& Request.Form("IntPerName") &"&#039"<BR><BR>Thanks in advance!!!

  2. #2
    Join Date
    Dec 1969

    Default RE: What is the correct syntax?

    I will assume that you populate a drop down box from a database with fields like<BR><BR>per_id _ Key field<BR>int_per_name text field<BR><BR>if So your drop down should look like<BR><BR>&#060;Select Name=IntPerName&#062;<BR>&#060;option value=1&#062;Joe Smith<BR>&#060;option value=2&#062;Tom Myers<BR>&#060;/select&#062;<BR><BR>so when do a request.form("IntPerName") the value you would get is the Key (1 or 2)<BR><BR>why do you need to insert the accual name into the new table if you are inserting the relative Id for that person? that is redundant data.<BR><BR>but if you have to do it I would do this<BR><BR>&#060;Select Name=IntPerName&#062;<BR>&#060;option&#062;1 - Joe Smith<BR>&#060;option&#062;2 - Tom Myers<BR>&#060;/select&#062;<BR><BR>then you could do<BR><BR>Str_P=Split(request.form("IntPerName"),"-")<BR><BR>insert into int_p (int_id, per_id, int_per_name) VALUES(&#039"& session("lngIntID") & "&#039, " & Str_P(0), &#039" & Str_P(1) & "&#039"<BR><BR>That is just my idea<BR><BR><BR><BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts