0

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

Edited by diya45

3
Contributors
2
Replies
3
Views
4 Years
Discussion Span
Last Post by arunkumars
0

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.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.