hi all

i update guestinfo all are update but the gender and martial status is not updated which is in comobox

here is the button code

private void button7_Click(object sender, EventArgs e)
        {



    guests myguest = new guests();
                myguest.Guest_id = Convert.ToInt32(guest_id.Text);

                    myguest.First_name = first_name.Text;
                    myguest.Last_name = last_name.Text;
                    myguest.Gender_status = Convert.ToString(gender_status.SelectedValue);
                    myguest.Martial_status = Convert.ToString(martial_status.SelectedValue);
                    myguest.Phone_numb = Convert.ToInt32(phone_numb.Text);
                    myguest.Email_address = email_id.Text;
                    myguest.update();
                    dataGridView1.DataSource = myguest.displaydata();
                    MessageBox.Show("Guest  Updated Successfully!", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    clearfield();

            }




        and i also create store procedure



 set ANSI_NULLS ON
    set QUOTED_IDENTIFIER ON
    GO
    ALTER procedure [dbo].[UpdateGUESTiNFO]



    @guest_id int,
    @First_name nvarchar(50),
    @last_name nvarchar(50),
    @gender nvarchar(50),
    @martial_status nvarchar(50),
    @phone_number int,
    @email_address nvarchar(50)
    as
    begin
    update GuestInfo
    set 
    first_name=@First_name,Last_name=@last_name,Phone_number=@phone_number,Email_address=@email_address
    where 
    guest_id=@guest_id


    END

    can anyone tell this problem

Recommended Answers

All 3 Replies

in this the when i run the code and press f10 in each line then in gender and martial the value is gven as null

You seem to be creating a new thread for the same discusion.
I suppose you copy and paste the whole code from internet and want it to work automatically, it wouldnt happen so, what ever you get over the internet is just a generic idea, you will have to customize that to your requirements (this advice since you are a beginner).
as far as the problem in code, the combo box you are trying to get the selected value is not returning any value, make sure you have added values into the combobox or listbox which is there in your application.

no...i can not copy and paste the code and this is my project so thts y i am askng

and in comobox i added values Single,married and female and male but the alwsays value is not given in girdview

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.