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 3678408
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:20:16+00:00 2026-05-19T03:20:16+00:00

I am pretty sure this is a basic syntax error, I am new at

  • 0

I am pretty sure this is a basic syntax error, I am new at this and basically figuring things out by trial and error… I am trying to insert data from textboxes into an Access database, where the primary key fields in tableCourse are prefix and course_number. It keeps giving me the “no value given for one or more required parameters” error. Here is my codebehind:

Protected Sub Wizard1_FinishButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles Wizard1.FinishButtonClick
    'Collect Data
    Dim myDept = txtDept.Text
    Dim myFirst = txtFirstName.Text
    Dim myLast = txtLastName.Text
    Dim myPrefix = txtCoursePrefix.Text
    Dim myNum = txtCourseNum.Text

    'Define Connection
    Dim myConn As New OleDbConnection
    myConn.ConnectionString = AccessDataSource1.ConnectionString

    'Create commands
    Dim myIns1 As New OleDbCommand("INSERT INTO tableCourse (department, name_first, name_last, prefix, course_number) VALUES (@myDept, @myFirst, @myLast, @myPrefix, @myNum)", myConn)

    'Execute the commands
    myConn.Open()
    myIns1.ExecuteNonQuery()
End Sub

EDIT: I have parameters inside of my AccessDataSource, is there a way to use those? Sorry if that’s a stupid question, I’m still learning this stuff and it really confuses me…

EDIT: Not really sure which answer to use, lol… I tried this:

Dim myIns1 As New OleDbCommand("INSERT INTO tableCourse (department, name_first, name_last, prefix, course_number) VALUES (?, ?, ?, ?, ?)", myConn)

    myIns1.Parameters.AddWithValue("@myDept", myDept)
    myIns1.Parameters.AddWithValue("@myFirst", myFirst)
    myIns1.Parameters.AddWithValue("@myLast", myLast)
    myIns1.Parameters.AddWithValue("@myPrefix", myPrefix)
    myIns1.Parameters.AddWithValue("@myNum", myNum)

And it inserts the data, I checked the database and it’s all there, but it still gives me an error:

“The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index, or redefine the index to permit duplicate entries and try again.”

  • 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-19T03:20:17+00:00Added an answer on May 19, 2026 at 3:20 am

    You need to do something like this:

    Protected Sub Wizard1_FinishButtonClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Handles Wizard1.FinishButtonClick
        'Collect Data
        Dim myDept = txtDept.Text
        Dim myFirst = txtFirstName.Text
        Dim myLast = txtLastName.Text
        Dim myPrefix = txtCoursePrefix.Text
        Dim myNum = txtCourseNum.Text
    
        'Define Connection
        Dim myConn As New OleDbConnection
        myConn.ConnectionString = AccessDataSource1.ConnectionString
    
        'Create commands
        Dim myIns1 As New OleDbCommand("INSERT INTO tableCourse (department, name_first, name_last, prefix, course_number) VALUES (@myDept, @myFirst, @myLast, @myPrefix, @myNum)", myConn)
    
         myIns1.Parameters.AddWithValue("@myDept", myDept)
         myIns1.Parameters.AddWithValue("@myFirst", myFirst)
         myIns1.Parameters.AddWithValue("@myLast", myLast)
         myIns1.Parameters.AddWithValue("@myPrefix", myPrefix)
         myIns1.Parameters.AddWithValue("@myNum", myNum)
        'Execute the commands
        myConn.Open()
        myIns1.ExecuteNonQuery()
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am pretty sure I have seen this before, but I haven't found out
I'm just getting rolling with RoR so I'm sure this is pretty basic. Let's
i am pretty sure this is basic but i just dont success to do
I'm pretty sure this is a basic question but for some reason i can't
I'm pretty sure this is a basic question but for some reason i can't
I'm pretty sure that this is a basic question but I really don't know
Pretty sure this question counts as blasphemy to most web 2.0 proponents, but I
I'm pretty sure this is a simple question in regards to formatting but here's
intro: I am pretty sure this is my fault. But I just don't see
I am pretty sure this is possible just not sure what is the term

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.