hi all

now guyz i add a info in datagrid view also displau now i hve some probelms that

when i create a update fuction in guestinfo table then the guest_id is autogenerte then can i delete through guest_id or not and it is also not updated

   public void update()
        {
            guests abc = new guests();
            {
                string ConString = @"Data Source=USER-PC\SQLEXPRESS;Initial Catalog=htm;Integrated Security=True";
                SqlConnection con = new SqlConnection(ConString);
                con.Open();
                SqlCommand com = new SqlCommand("UpdateGUESTiNFO", con);
                com.CommandType = CommandType.StoredProcedure;

in bcak the form of guestinfo code is
            gst.update();
            gst.First_name = first_name.Text.ToString();
            gst.Last_name = last_name.Text.ToString();
            gst.Phone_numb = Convert.ToInt32(phone_numb.Text);
            gst.Email_address = email_id.Text.ToString();

            stroe procedure is 

            create procedure UpdateGUESTiNFO



@GUEST_id INT,
@First_name nvarchar(50),
@last_name 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

Recommended Answers

All 2 Replies

Yes you can delete the guest, see MSDN's explanation of a SQL Delete statement.

You need to set the parameters for your update function, see the SqlCommand.CreateParameter function.

Well, see, your stored procedure requires the guest_id as the first parameter, but you dont seem to send that thru the procedure.
Hint : you can actually have a variable named guest_id in ur appication and you can fill the varaible when u retrieve it.
during an update you can send the same variable as a parameter.

YES, Deleting through autogenerated is very much possible.

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.