put some breakpoints at different parts of the code, you can then step into the code and try to isolate the area where it hangs. You might have a long running query, infinite loop etc.
Also, post your code, as others might spot any mistakes.
Please remember to Mark As Answer if helpful
Regards, Christiandev (@chrisdev80), MCPD Web (2 & 4) & MCTS Windows (www.ScoreDonkey.com)
put some breakpoints at different parts of the code, you can then step into the code and try to isolate the area where it hangs. You might have a long running query, infinite loop etc.
Also, post your code, as others might spot any mistakes.
This is my code [ Events code]:
Imports System.Data.SqlClient
Imports System.data
Imports Microsoft.Win32
Partial Class PersonCRM
Inherits
System.Web.UI.Page
ProtectedSub Page_Load(ByVal
sender AsObject,
ByVal e
As System.EventArgs)
HandlesMe.Load
Try
IfNot Page.IsPostBack
Then
Dim
x AsNew Person
Dim
dt As DataTable = x.find()
GVperson.DataSource = dt
GVperson.DataBind()
EndIf
Catch
ex As Exception
MsgBox(ex.Message &
"
ERROR Page_Load ")
EndTry
EndSub
ProtectedSub GVperson_RowDataBound(ByVal
sender AsObject,
ByVal e
As System.Web.UI.WebControls.GridViewRowEventArgs)
Handles GVperson.RowDataBound
If
e.Row.RowType = DataControlRowType.DataRow Then
Dim
txtID As TextBox =
CType(e.Row.FindControl("txtID"),
TextBox)
Dim
txtfname As TextBox =
CType(e.Row.FindControl("txtfname"),
TextBox)
Dim
txtlname As TextBox =
CType(e.Row.FindControl("txtlname"),
TextBox)
Dim
txtphone As TextBox =
CType(e.Row.FindControl("txtphone"),
TextBox)
Dim
x AsNew Person
If
x.idPRO.ToString() = Nothing
Then
txtID.Text = 0
EndIf
If
x.FNAMEPRO.Trim() = NothingThen
txtfname.Text = 0
EndIf
If
x.LNAMEPRO.Trim() = NothingThen
txtlname.Text = 0
EndIf
If
x.phonePRO.Trim() = NothingThen
txtphone.Text = 0
EndIf
EndIf
EndSub
ProtectedSub GVPERSON_RowUpdating(ByVal
sender AsObject,
ByVal e
As System.Web.UI.WebControls.GridViewUpdateEventArgs)
Handles GVperson.RowUpdating
Try
Dim
row As GridViewRow =
DirectCast(GVperson.Rows(e.RowIndex), GridViewRow)
Dim
id AsInteger
Dim
phone AsString
Dim
fname AsString
Dim
lname AsString
Dim
txt As TextBox
txt =CType(row.FindControl("txtId"),
TextBox)
id = txt.Text.Trim
txt =CType(row.FindControl("txtphone"),
TextBox)
phone = txt.Text.Trim
txt =CType(row.FindControl("txtfname"),
TextBox)
fname = txt.Text.Trim
txt =CType(row.FindControl("txtlname"),
TextBox)
lname = txt.Text.Trim
Dim
objper AsNew Person
objper.UPDATE()
Dim
DT As DataTable = objper.find()
GVperson.DataSource = DT
GVperson.DataBind()
Catch
ex As Exception
MsgBox(ex.Message &
"
CAN NOT update DATA")
EndTry
EndSub
ProtectedSub GVPERSON_RowDeleting(ByVal
sender AsObject,
ByVal e
As System.Web.UI.WebControls.GridViewDeleteEventArgs)
Handles GVperson.RowDeleting
Try
Dim
row As GridViewRow =
DirectCast(GVperson.Rows(e.RowIndex), GridViewRow)
Dim
id AsInteger
Dim
phone AsString
Dim
fname AsString
Dim
lname AsString
Dim
txt As TextBox
txt =
CType(row.FindControl("txtid"),
TextBox)
id = txt.Text.Trim()
txt =
CType(row.FindControl("txtphone"),
TextBox)
phone = txt.Text.Trim()
txt =
CType(row.FindControl("txtfname"),
TextBox)
fname = txt.Text.Trim()
txt =
CType(row.FindControl("txtlname"),
TextBox)
lname = txt.Text.Trim()
Dim
objper AsNew Person
objper.delete()
Dim
DT As DataTable = objper.find()
GVperson.DataSource = DT
GVperson.DataBind()
Catch
ex As Exception
MsgBox(ex.Message &
" CAN NOT delete DATA ")
EndTry
EndSub
ProtectedSub Buttonshow_Click(ByVal
sender AsObject,
ByVal e
As System.EventArgs)
Handles Buttonshow.Click
Dim
x AsNew Person
Dim
dt As DataTable = x.find()
GVperson.DataSource = dt
GVperson.DataBind()
EndSub
End Class .
//
CLASS NAME TABLE PERSON CODE :
Imports
System.Data
Imports
System.Data.SqlClient
Imports
Microsoft.win32
Public
Class Person
Private
ID AsInteger = 0
Private
phone AsString =
" "
Private
FNAME AsString =
" "
Private
LNAME AsString =
" "
Private
CONN AsNew SqlConnection
PublicProperty idPRO()
As
Integer
Get
Return
ID
EndGet
Set(ByVal
value AsInteger)
ID = value
End
Set
EndProperty
PublicProperty phonePRO()
AsString
Get
Return
phone
End
Get
Set(ByVal
value AsString)
phone = value
End
Set
EndProperty
PublicProperty FNAMEPRO()
AsString
Get
Return
FNAME
EndGet
Set(ByVal
value AsString)
FNAME = value
EndSet
EndProperty
PublicProperty LNAMEPRO()
AsString
Get
Return
LNAME
EndGet
Set(ByVal
value AsString)
LNAME = value
EndSet
EndProperty
PublicSub GETCONNECTION()
Try
CONN =
New
SqlConnection(DBConnection.constr)
CONN.Open()
Catch
ex As Exception
MsgBox(ex.Message &
"CANOT
OPEN DATABASE ")
Finally
CONN.Close()
EndTry
EndSub
PublicSub UPDATE()
GETCONNECTION()
Dim
SQL AsString =
" update Person set Pers_PersonId = @PID , Pers_PhoneNumber =@phone , Pers_FirstName=@FNAME ,Pers_LastName = @LNAME
WHERE Pers_PersonId = @PID "
Dim
cmd AsNew SqlCommand(SQL, CONN)
cmd.Parameters.Add(
"@PID",
SqlDbType.Int).Value = ID
cmd.Parameters.Add(
"@phone",
SqlDbType.NChar).Value = phone
cmd.Parameters.Add(
"@FNAME",
SqlDbType.NChar).Value = FNAME
cmd.Parameters.Add(
"@LNAME",
SqlDbType.NChar).Value = LNAME
Try
CONN.Open()
cmd.ExecuteNonQuery()
Catch
ex As Exception
MsgBox(ex.Message &
"
ERROR UPDATE ")
EndTry
EndSub
PublicSub delete()
GETCONNECTION()
Dim
sql AsString =
" Delete from Person where Pers_PersonId =@PID "
Dim
cmd AsNew SqlCommand(sql, CONN)
cmd.Parameters.Add(
"@PID",
SqlDbType.Int).Value = ID
cmd.Parameters.Add(
"@phone",
SqlDbType.NChar).Value = phone
cmd.Parameters.Add(
"@FNAME",
SqlDbType.NChar).Value = FNAME
cmd.Parameters.Add(
"@LNAME",
SqlDbType.NChar).Value = LNAME
Try
CONN.Open()
cmd.ExecuteNonQuery()
Catch
ex As Exception
MsgBox(ex.Message &
"
Error Deleted ")
EndTry
EndSub
PublicFunction find()
As DataTable
GETCONNECTION()
Dim
sql AsString =
" Select Pers_PersonId , Pers_FirstName , Pers_LastName , Pers_PhoneNumber from Person where 1 = 1 "
Mohammed Sal...
Member
14 Points
208 Posts
Hang System VS 2005 VB.NET
Oct 24, 2012 07:37 AM|LINK
WHEN I Run my system it's Hang ,no show gridview(data) ,no complete run
please help me
ToughMan
Participant
1490 Points
635 Posts
Re: Hang System VS 2005 VB.NET
Oct 24, 2012 07:40 AM|LINK
Too generic……, what codes have u written???
christiandev
Star
8607 Points
1841 Posts
Re: Hang System VS 2005 VB.NET
Oct 24, 2012 07:43 AM|LINK
put some breakpoints at different parts of the code, you can then step into the code and try to isolate the area where it hangs. You might have a long running query, infinite loop etc.
Also, post your code, as others might spot any mistakes.
Regards, Christiandev (@chrisdev80), MCPD Web (2 & 4) & MCTS Windows (www.ScoreDonkey.com)
Mohammed Sal...
Member
14 Points
208 Posts
Re: Hang System VS 2005 VB.NET
Oct 24, 2012 07:53 AM|LINK
This is my code [ Events code]:
Imports System.Data.SqlClient
Imports System.data
Imports Microsoft.Win32
Partial Class PersonCRM
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
If Not Page.IsPostBack Then
Dim x As New Person
Dim dt As DataTable = x.find()
GVperson.DataSource = dt
GVperson.DataBind()
End If
Catch ex As Exception
MsgBox(ex.Message &
" ERROR Page_Load ")
End Try
End Sub
Protected Sub GVperson_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVperson.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then
Dim txtID As TextBox = CType(e.Row.FindControl("txtID"), TextBox)
Dim txtfname As TextBox = CType(e.Row.FindControl("txtfname"), TextBox)
Dim txtlname As TextBox = CType(e.Row.FindControl("txtlname"), TextBox)
Dim txtphone As TextBox = CType(e.Row.FindControl("txtphone"), TextBox)
Dim x As New Person
If x.idPRO.ToString() = Nothing
Then
txtID.Text = 0
End If
If x.FNAMEPRO.Trim() = Nothing Then
txtfname.Text = 0
End If
If x.LNAMEPRO.Trim() = Nothing Then
txtlname.Text = 0
End If
If x.phonePRO.Trim() = Nothing Then
txtphone.Text = 0
End If
End If
End Sub
Protected Sub GVPERSON_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GVperson.RowUpdating
Try
Dim row As GridViewRow = DirectCast(GVperson.Rows(e.RowIndex), GridViewRow)
Dim id As Integer
Dim phone As String
Dim fname As String
Dim lname As String
Dim txt As TextBox
txt =CType(row.FindControl("txtId"), TextBox)
id = txt.Text.Trim
txt =CType(row.FindControl("txtphone"), TextBox)
phone = txt.Text.Trim
txt =CType(row.FindControl("txtfname"), TextBox)
fname = txt.Text.Trim
txt =CType(row.FindControl("txtlname"), TextBox)
lname = txt.Text.Trim
Dim objper As New Person
objper.UPDATE()
Dim DT As DataTable = objper.find()
GVperson.DataSource = DT
GVperson.DataBind()
Catch ex As Exception
MsgBox(ex.Message &
" CAN NOT update DATA")
End Try
End Sub
Protected Sub GVPERSON_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GVperson.RowDeleting
Try
Dim row As GridViewRow = DirectCast(GVperson.Rows(e.RowIndex), GridViewRow)
Dim id As Integer
Dim phone As String
Dim fname As String
Dim lname As String
Dim txt As TextBox
txt =
CType(row.FindControl("txtid"), TextBox)
id = txt.Text.Trim()
txt =
CType(row.FindControl("txtphone"), TextBox)
phone = txt.Text.Trim()
txt =
CType(row.FindControl("txtfname"), TextBox)
fname = txt.Text.Trim()
txt =
CType(row.FindControl("txtlname"), TextBox)
lname = txt.Text.Trim()
Dim objper As New Person
objper.delete()
Dim DT As DataTable = objper.find()
GVperson.DataSource = DT
GVperson.DataBind()
Catch ex As Exception
MsgBox(ex.Message &
" CAN NOT delete DATA ")
End Try
End Sub
Protected Sub Buttonshow_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Buttonshow.Click
Dim x As New Person
Dim dt As DataTable = x.find()
GVperson.DataSource = dt
GVperson.DataBind()
End Sub
End Class .
//
CLASS NAME TABLE PERSON CODE :
Imports
System.Data
Imports
System.Data.SqlClient
Imports
Microsoft.win32
Public
Class Person
Private ID As Integer = 0
Private phone As String = " "
Private FNAME As String = " "
Private LNAME As String = " "
Private CONN As New SqlConnection
Public Property idPRO() As
Integer
Get
Return ID
End Get
Set(ByVal value As Integer)
ID = value
End
Set
End Property
Public Property phonePRO() As String
Get
Return phone
End
Get
Set(ByVal value As String)
phone = value
End
Set
End Property
Public Property FNAMEPRO() As String
Get
Return FNAME
End Get
Set(ByVal value As String)
FNAME = value
End Set
End Property
Public Property LNAMEPRO() As String
Get
Return LNAME
End Get
Set(ByVal value As String)
LNAME = value
End Set
End Property
Public Sub GETCONNECTION()
Try
CONN =
New SqlConnection(DBConnection.constr)
CONN.Open()
Catch ex As Exception
MsgBox(ex.Message &
"CANOT OPEN DATABASE ")
Finally
CONN.Close()
End Try
End Sub
Public Sub UPDATE()
GETCONNECTION()
Dim SQL As String = " update Person set Pers_PersonId = @PID , Pers_PhoneNumber =@phone , Pers_FirstName=@FNAME ,Pers_LastName = @LNAME WHERE Pers_PersonId = @PID "
Dim cmd As New SqlCommand(SQL, CONN)
cmd.Parameters.Add(
"@PID", SqlDbType.Int).Value = ID
cmd.Parameters.Add(
"@phone", SqlDbType.NChar).Value = phone
cmd.Parameters.Add(
"@FNAME", SqlDbType.NChar).Value = FNAME
cmd.Parameters.Add(
"@LNAME", SqlDbType.NChar).Value = LNAME
Try
CONN.Open()
cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message &
" ERROR UPDATE ")
End Try
End Sub
Public Sub delete()
GETCONNECTION()
Dim sql As String = " Delete from Person where Pers_PersonId =@PID "
Dim cmd As New SqlCommand(sql, CONN)
cmd.Parameters.Add(
"@PID", SqlDbType.Int).Value = ID
cmd.Parameters.Add(
"@phone", SqlDbType.NChar).Value = phone
cmd.Parameters.Add(
"@FNAME", SqlDbType.NChar).Value = FNAME
cmd.Parameters.Add(
"@LNAME", SqlDbType.NChar).Value = LNAME
Try
CONN.Open()
cmd.ExecuteNonQuery()
Catch ex As Exception
MsgBox(ex.Message &
" Error Deleted ")
End Try
End Sub
Public Function find() As DataTable
GETCONNECTION()
Dim sql As String = " Select Pers_PersonId , Pers_FirstName , Pers_LastName , Pers_PhoneNumber from Person where 1 = 1 "
Dim dt As New DataTable
Dim da As New SqlDataAdapter(sql, CONN)
If ID <> 0 Then
da.SelectCommand.CommandText &=
" AND Pers_PersonId=@PID"
da.SelectCommand.Parameters.Add(
"@PID", SqlDbType.Int).Value = ID
End If
If phone <> " " Then
da.SelectCommand.CommandText &=
" AND Pers_PhoneNumber=@phone"
da.SelectCommand.Parameters.Add(
"@phone", SqlDbType.NChar).Value = phone
End If
If FNAME <> " " Then
da.SelectCommand.CommandText &=
" And Pers_FirstName=@FName"
da.SelectCommand.Parameters.Add(
"@FNAME", SqlDbType.NChar).Value = FNAME
End If
If LNAME <> " " Then
da.SelectCommand.CommandText &=
" AND Pers_LastName=@LNAME"
da.SelectCommand.Parameters.Add(
"@LNAME", SqlDbType.NChar).Value = LNAME
End If
Try
da.Fill(dt)
CONN.Open()
Catch ex As Exception
MsgBox(ex.Message &" Cannot fill ")
Finally
CONN.Close()
End Try
Return dt
End Function
End Class
christiandev
Star
8607 Points
1841 Posts
Re: Hang System VS 2005 VB.NET
Oct 24, 2012 07:58 AM|LINK
Put a breakpoint on the IF NOT Page.ISPostBack and step into the code and see where it starts to hang. What does Person.Find() do?
Regards, Christiandev (@chrisdev80), MCPD Web (2 & 4) & MCTS Windows (www.ScoreDonkey.com)
Mohammed Sal...
Member
14 Points
208 Posts
Re: Hang System VS 2005 VB.NET
Oct 24, 2012 08:20 AM|LINK
FROM NOT PAGE.ISPOETBACK ,STEP TO STEP TO END SOURCE CODE RETURN ROWDATABOUND (STEP TO STEP )
OBJPER.FIND() GO TO CHECK FROM FIND STEP TO STEP .NO ERRORRS HERE
WHEN FINISH SOURCODE RETURN TO ROWDATABOUND ,
it started from event rowdatabound
Protected Sub GVperson_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GVperson.RowDataBound
ToughMan
Participant
1490 Points
635 Posts
Re: Hang System VS 2005 VB.NET
Oct 24, 2012 08:52 AM|LINK
Dead loop?
Mohammed Sal...
Member
14 Points
208 Posts
Re: Hang System VS 2005 VB.NET
Oct 24, 2012 09:26 AM|LINK
I insert event pageindexchanging but nothing
I can't know wher this loop in my code ?
how know it ?
Mohammed Sal...
Member
14 Points
208 Posts
Re: Hang System VS 2005 VB.NET
Oct 30, 2012 08:02 AM|LINK
know this code give data grid view but not update not deleted why ?
Please , help me
Mohammed Sal...
Member
14 Points
208 Posts
Re: Hang System VS 2005 VB.NET
Nov 04, 2012 06:40 AM|LINK
I Solution this problem :
The Solution :
INSERT EVENT PAGEINDEXCHANGING ?
ALLOW PAGING FOR GRIDVIEW INPROPERTIES