Problem in storing values from Executescaler() (inside a data grid

Discussion in 'ASP .Net' started by =?Utf-8?B?dmVsdQ==?=, Sep 19, 2005.

  1. Problem in storing values from Executescaler() (inside a data grid.)

    Situation:

    I have placed a panel inside a datagrid, which populate a table from a
    database. Now, I run a query to compare that the user ip address with the
    database. If the query fetches a record. The panel is set to visible else
    other textbox set to visible. Following are the code below.

    Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As
    System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
    DataGrid1.ItemCommand

    Select Case e.CommandName

    Case "Open_panel"
    ' users IP address.
    Dim UserIP As String
    UserIP = (Request.UserHostAddress)
    ' Get the IP address from database
    'Open the connection, and execute the query...
    Dim intCount As Integer
    Dim cmdvrfy As SqlCommand
    cmdvrfy = New SqlCommand("Select COUNT(*) As RatingCount
    FROM tbl_rating Where DocumentID =" & DocumentID & "AND ip ='" & UserIP &
    "';", conPubs)
    conPubs.Open()
    cmdvrfy.Connection = conPubs
    cmdvrfy.CommandType = CommandType.Text

    intCount = cmdvrfy.ExecuteScalar()
    conPubs.Close()
    If intCount = 0 Then '127.0.0.1
    'Opens the Panel for the user !
    e.Item.FindControl("Panel1").Visible = True

    Else
    e.Item.FindControl("Label1").Visible = True
    End If

    But the value for intCount is showing me as zero even though the table
    contain 4 record of that ip and DocumentID..i exactly don’t know where the
    problem is..any thoughts of you will be a great help for me…


    Thx
    Jk
     
    =?Utf-8?B?dmVsdQ==?=, Sep 19, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. nobody
    Replies:
    1
    Views:
    539
    Venkatesh
    Apr 26, 2006
  2. Replies:
    1
    Views:
    378
    Brandon McCombs
    Sep 25, 2006
  3. toton
    Replies:
    11
    Views:
    714
    toton
    Oct 13, 2006
  4. Jonathan Wood
    Replies:
    1
    Views:
    511
    Jonathan Wood
    Jun 2, 2008
  5. Albert
    Replies:
    11
    Views:
    649
    CBFalconer
    Jan 31, 2009
Loading...

Share This Page