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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T15:48:06+00:00 2026-06-01T15:48:06+00:00

I’m trying to create a Windows Form application in C#, mostly just to practice

  • 0

I’m trying to create a Windows Form application in C#, mostly just to practice what I learned in university. My database is an Access database made up of three tables (SetIndex, SetSong [a junction table], and Song). We never learned how to use a database in an application, just in a web site. Most of what I’ve learned, I’ve learned through trial and error.

I have a combobox list with dates from the SetIndex table, the value being the ID (the primary key of SetIndex). I need to be able to query the database with a select statement that says setindex.id = setsong.setid and setsong.songid = song.id and setIndex.id = a variable, the chosen value from the dropdown list. I wrote a select statement in Access using (setindex.id = ?) that works just fine in Access, but I haven’t figured out how to do it in C#. I’ve found answers about how to use parameters and how to query multiple tables, but nothing that combines the two.

So is there a way to do it within the code?

This is the last thing I tried:

using (OleDbConnection dataConnection = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Mandy\Documents\Visual Studio 2010\Projects\SetManager1.3\SetManager1.3\SetManager.accdb"))
{
    using (OleDbCommand dataCommand = dataConnection.CreateCommand())
    {
        dataCommand.CommandText = "SELECT Title FROM Song WHERE Song.ID = SetSong.SongID AND SetIndex.ID=SetSong.SetID AND SetIndex.ID=@ID";
        dataConnection.Open();
        dataCommand.Parameters.AddWithValue("@ID", ID);
        DataTable table = new DataTable();
        OleDbDataAdapter adapter = new OleDbDataAdapter();
        adapter.SelectCommand = dataCommand;
        adapter.Fill(table);
        bindingSource1.DataSource = table;
        dataGridView1.AutoResizeColums(DataGridViewAutoSizeColumnsMode.AllCellsExceptHeader);
        dataGridView1.ReadOnly = true;
        dataGridView1.DataSource = bindingSource1;
    }
}

ID is an int variable that comes from a global class that takes the ID value from the combo box listing the dates (the value of the selected SetIndex.ID). I tested to make sure this part was working by using a label and a button and it seems to be retrieving the value, storing it in GlobalClass.ViewBySetDate, and converting it to my int ID just fine.

But this is coming up with the error “No value given for one or more required parameters.”

Is there a better/working way to do this? Or, if not, how do I fix the error?

Thank you in advance,

Mandy

Edit: I changed the Select statement to the following:

SELECT song.Title FROM SetIndex INNER JOIN (song INNER JOIN SetSong ON song.ID = SetSong.SongID) ON SetIndex.ID = SetSong.SetID WHERE ((set index.id) =[?]);

The error is no more, but the datagridview is still blank.

  • 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-06-01T15:48:08+00:00Added an answer on June 1, 2026 at 3:48 pm

    Test you query in the database.. the method is the same to access the database, but your query is wrong

    SELECT Title FROM Song WHERE Song.ID = SetSong.SongID AND SetIndex.ID=SetSong.SetID AND SetIndex.ID=@ID
    

    SetSong is not defined inside the query.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I'm trying to create an if statement in PHP that prevents a single post
I have a reasonable size flat file database of text documents mostly saved in
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from

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.