View Single Post
  #23 (permalink)  
Old July 15th, 2011, 03:43 AM
priti2010 priti2010 is offline
Authorized User
Points: 63, Level: 1
Points: 63, Level: 1 Points: 63, Level: 1 Points: 63, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2011
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default Please let me know how to solved this error

I have modify my code but now i am getting a error "Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index "
Protected Sub DataGridOdin_RowDeleting1(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles DataGridOdin.RowDeleting
Try
Dim Service_ID As [String]
Service_ID = DataGridOdin.DataKeys(e.RowIndex).Value.ToString()
mycommand = New SqlCommand("sp_ServiceDel", myconnection)
myconnection.Open()
mycommand.CommandType = CommandType.StoredProcedure
mycommand.Parameters.Add("@Service_ID", SqlDbType.Int).Value = Convert.ToInt32(Service_ID)
mycommand.ExecuteReader()
myconnection.Close()
Bindgrid()

Catch ex As Exception
Response.Write(ex.Message)
End Try


End Sub

---my stored procedure is as follows--
CREATE PROCEDURE [dbo].[sp_ServiceDel]
-- Add the parameters for the stored procedure here
@Service_ID int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
DELETE tbl_Service from tbl_Service
where Service_ID = @Service_ID

END