Answered by:
Hang System VS 2005 VB.NET

Question
-
User910710390 posted
WHEN I Run my system it's Hang ,no show gridview(data) ,no complete run
please help me
Wednesday, October 24, 2012 3:37 AM
Answers
-
User910710390 posted
I Solution this problem :
The Solution :
INSERT EVENT PAGEINDEXCHANGING ?
ALLOW PAGING FOR GRIDVIEW INPROPERTIES
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, November 4, 2012 2:40 AM
All replies
-
User-134477160 posted
WHEN I Run my system it's Hang ,no show gridview(data) ,no complete runToo generic……, what codes have u written???
Wednesday, October 24, 2012 3:40 AM -
User750226543 posted
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.
Wednesday, October 24, 2012 3:43 AM -
User910710390 posted
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
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
Wednesday, October 24, 2012 3:53 AM -
User750226543 posted
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?
Wednesday, October 24, 2012 3:58 AM -
User910710390 posted
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?
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
Wednesday, October 24, 2012 4:20 AM -
Wednesday, October 24, 2012 4:52 AM
-
User910710390 posted
Dead loop ?
I insert event pageindexchanging but nothing
I can't know wher this loop in my code ?
how know it ?
Wednesday, October 24, 2012 5:26 AM -
User910710390 posted
know this code give data grid view but not update not deleted why ?
Please , help me
Tuesday, October 30, 2012 4:02 AM -
User910710390 posted
I Solution this problem :
The Solution :
INSERT EVENT PAGEINDEXCHANGING ?
ALLOW PAGING FOR GRIDVIEW INPROPERTIES
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, November 4, 2012 2:40 AM