Print Page | Close Window

Table select

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Database Discussion
Forum Description: Discussion and chat on database related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=7791
Printed Date: 28 March 2026 at 4:08am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Table select
Posted By: RedRaver
Subject: Table select
Date Posted: 02 December 2003 at 9:40am

Hi there,

I have a db with tables according to the topics.

I would like to create a form with a drop down where you can select the topic, and acording the topic you select. The filled in fields go to that table...

So the name of the table should be replaced with what is selected in the from (in this case sales_comm)

I have this as code to add to the db:

<%
   ' Declaring variables
   Dim titles, sizes, group, sql_insert

   ' Receiving values from Form
   sizes = Request.Form("sizes")
   titles = Request.Form("titles")
   group = Request.Form("group")

   data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("Intranet.mdb")
  
   sql_insert = "insert into sales_comm (titles, sizes) values ('" & titles & "', '" & sizes & "')"
   
   ' Creating Connection Object and opening the database
   Set con = Server.CreateObject("ADODB.Connection")
   con.Open data_source
   con.Execute sql_insert
   ' Done. Close the connection
   con.Close
   Set con = Nothing
  
   Response.Write "All records were successfully entered into the database."
%>

===================================================

and this as form:

<p>
  <select size="1" name="group">
    <option value="sales_comm">sales comm</option>
    <option value="corp_comm">corp comm</option>
  </select>
</p>
<p>Title<br>
      <input type="text" size="40" name="titles">
      <br>
    Size<br>
    <input type="text" size="40" name="sizes">
    <br>
    date<br>
    <input type="text" size="40" name="date">
    <br>
    download eu<br>
    <input type="text" size="40" name="download_eu">
    <br>
    download us<br>
    <input type="text" size="40" name="download_us">
    <br>
    view eu<br>
    <input type="text" size="40" name="view_eu">
    <br>
    view us<br>
    <input type="text" size="40" name="view_us">
    </p>
<p>
      <input type="Submit" value="Submit" name"Submit">
      </font>
</p>
</form>

Cheerzzz
RedRaver




Replies:
Posted By: Semikolon
Date Posted: 07 December 2003 at 9:08am

dim table

table = Request.Form("group")

 

 sql_insert = "insert into " & table & " (titles, sizes) values ('" & titles & "', '" & sizes & "')"

did i understand you right?




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net