Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7182899
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:52:08+00:00 2026-05-28T17:52:08+00:00

i am developing my app on visual studio 2008 i have 4 tables i

  • 0
  • i am developing my app on visual studio 2008
  • i have 4 tables
  • i have a dropdownlist (displays product_category_names)
  • i need to do an insert statement
  • i have the following code:

    Dim sql2 As String = “INSERT INTO Product (product_category_id, product_name, product_title, product_desc, product_author, product_author_age, product_author_desc, product_other_detail, product_dimension1, product_dimension2, product_price, product_institution, product_status, product_delivery_time) VALUES (@product_category_id, @product_name, @product_title, @product_desc, @product_author, @product_author_age, @product_author_desc, @product_other_detail, @product_dimension1, @product_dimension2, @product_price, @product_institution, @product_status, @product_delivery_time)”

cmd.Parameters.Add(New SqlParameter(“@product_name”, (txtProductName2.Text)))
cmd.Parameters.Add(New SqlParameter(“@product_title”, (txtProductTitle2.Text)))

Question is, how may I insert ‘product_category_id’ (an Integer) into the table ‘Product’, when the dropdownlist displays ‘product_category_names’ instead of ‘product_category_id’?

Can someone show me the light? Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T17:52:09+00:00Added an answer on May 28, 2026 at 5:52 pm

    Assuming you are binding your dropdownlist on the page load event and using the product_Catogry table then The easiest way would be to bind product_category_ID to the value property of the dropdownlist. This way you can programatically access the ID while the user sees the name.

    DropDownList.DataSource = [your product table]
    DropDownList.DataTextField = "Proudct_Category_Name"
    DropDownList.DataValueField = "Product_category_ID"
    

    If this is not an option for whatever reason then the below SQL will work in your current command, just make sure you add @Product_Category_Name as a parameter to the SqlCommand instead of @product_Category_Name.

    INSERT INTO Product 
    (       product_category_id, 
            product_name, 
            product_title, 
            product_desc, 
            product_author, 
            product_author_age, 
            product_author_desc, 
            product_other_detail, 
            product_dimension1, 
            product_dimension2, 
            product_price, 
            product_institution, 
            product_status, 
            product_delivery_time
    )    
    SELECT  product_category_id, 
            @product_name, 
            @product_title, 
            @product_desc, 
            @product_author, 
            @product_author_age, 
            @product_author_desc, 
            @product_other_detail, 
            @product_dimension1, 
            @product_dimension2, 
            @product_price, 
            @product_institution, 
            @product_status, 
            @product_delivery_time
    FROM    product_category
    WHERE   product_category_Name = @Product_Category_Name
    

    Or you could simply add this to the start of your current SQL:

    DECLARE  @Product_Category_ID INT
    SELECT   @Product_Category_ID = Product_Category_ID
    FROM     Product_Category
    WHERE    Product_Category_Name = @Product_Category_Name
    

    And continue with the insert … values ().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app that I am developing in Visual Studio 2008, but the
I'm using Visual Studio 2008, developing a winforms app. I have my database connection
I'm developing an ASP.NET 2.0 app using Visual Studio 2008. If I want to
I am developing a Windows CE App using Visual Studio 2008 and the Compact
So I've been developing on Windows XP Visual Studio 2008. I guess it is
I am developing an app on Visual Studio with mono for Android C#. How
I am developing an add-in for MS Project in Visual Studio and I need
I'm developing an app in Visual C++ that uses an SQLite3 DB for storing
I am developing a C# WinForms app on my XP dev machine with Visual
While developing my app I have come to realize that the majority of my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.