Hi, I was wondering if someone could please help me. I have an access database with two tables. One table is Movie and the other is Genre all in a relationship. I have a foreign key in Movie pointing to Genre. My Movie table looks like this "MovieID, MovieName, GenreFK". My Genre table looks like this "GenreID, GenreName". My problem is when I create an input form. I don't want the drop down box to show the FK number but instead the GenreName. And I submit The Movie table should have the right number on the FK. I hope this makes sense please please can someone help me.

Ok, first i imagine you have a dropdownlist to display all genres in the new movie entry form. is that is the case you will have a select statment like. select GenreID, GenreName from Genre then fill a dataset with that result, lets say the dataset is called dsGenres so to fill the dropdown you will have this.

DropDown.DataSource = dsGenre;
DropDown.DataTextField = "GenreName";
DropDown.DataValueField = "GenreID";

Then to retrieve the key in the insert statement you need to say this


I hope that help you a little bit.

Thanks I will try it but doesn't the select statement need details of the other table I am rather new to C#

In my opinion, regardless the operation in issue (Insert a new record or displaying data from db) you need to fill the dropdown with all values from genre table.

Now if you want to display a specific genre belongs to a movie i guess you will have a datareader or something like that to retreive those values, select MovieID, MovieName, GenreFK from movies now the c# is imagine the datareader is called dr

DropDown.Items.FindByValue(dr[2]).Selected = true;

remember for dr[2] you have to make the cast to integer if its the case.