G
Guest
{Remember Everything happens inside a DATAGRID}
Situation: I have a datagrid that populates a query from SQL. I have added
another column to it. Now I have placed a link button and a Panel. Initially
the panel is set to visible as OFF.
My need is : I altuaclly need to get he user IP address and verify that with
the database. If the user ip addess is in the database then the Panel is not
set to ON. If the user IP address is not there in the table then the Panel is
set to visiable as ON.
My Solution :
Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
DataGrid1.ItemCommand
' 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 ip FROM tbl_rating Where DocumentID
=" & DocumentID & "AND ip =" & UserIP, conPubs)
conPubs.Open()
'cmdvrfy.Connection = conPubs
'cmdvrfy.CommandType = CommandType.Text
intCount = cmdvrfy.ExecuteScalar
cmdvrfy.ExecuteScalar()
conPubs.Close()
If intCount = "" Then '127.0.0.1
'Opens the Panel for the user !
Dim MyPanel As Panel
MyPanel = (e.Item.FindControl("Panel1"))
MyPanel.Visible = True
Else
End If
End Sub
But I get this error and I exactly dint have any idea on how to proceed
Erroe :
Exception Details: System.Data.SqlClient.SqlException: Line 1: Incorrect
syntax near '.0'.
Source Error:
Line 82: 'cmdvrfy.Connection = conPubs
Line 83: 'cmdvrfy.CommandType = CommandType.Text
Line 84: intCount = cmdvrfy.ExecuteScalar
Line 85: cmdvrfy.ExecuteScalar()
Line 86: conPubs.Close()
Let me know ur thoughts.
Situation: I have a datagrid that populates a query from SQL. I have added
another column to it. Now I have placed a link button and a Panel. Initially
the panel is set to visible as OFF.
My need is : I altuaclly need to get he user IP address and verify that with
the database. If the user ip addess is in the database then the Panel is not
set to ON. If the user IP address is not there in the table then the Panel is
set to visiable as ON.
My Solution :
Private Sub DataGrid1_ItemCommand(ByVal source As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs) Handles
DataGrid1.ItemCommand
' 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 ip FROM tbl_rating Where DocumentID
=" & DocumentID & "AND ip =" & UserIP, conPubs)
conPubs.Open()
'cmdvrfy.Connection = conPubs
'cmdvrfy.CommandType = CommandType.Text
intCount = cmdvrfy.ExecuteScalar
cmdvrfy.ExecuteScalar()
conPubs.Close()
If intCount = "" Then '127.0.0.1
'Opens the Panel for the user !
Dim MyPanel As Panel
MyPanel = (e.Item.FindControl("Panel1"))
MyPanel.Visible = True
Else
End If
End Sub
But I get this error and I exactly dint have any idea on how to proceed
Erroe :
Exception Details: System.Data.SqlClient.SqlException: Line 1: Incorrect
syntax near '.0'.
Source Error:
Line 82: 'cmdvrfy.Connection = conPubs
Line 83: 'cmdvrfy.CommandType = CommandType.Text
Line 84: intCount = cmdvrfy.ExecuteScalar
Line 85: cmdvrfy.ExecuteScalar()
Line 86: conPubs.Close()
Let me know ur thoughts.