Everything happens inside a datagrid, a Complex one ?

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.
 
G

Guest

Hi, why did you call the cmdvrfy.ExecuteScalar() twice ? I think the second
one isn't necessary. And, what is the datatype of IP field in your database ?
 
G

Guest

Hi alvinz_c,

cmdvrfy.ExecuteScalar() in the secound line is comment (sorry about that...)

and Ip field in my databse is a string..!

My main idea is to compair the IP in the datebase with the document ID so
than when the IP exist then the user is not allowed to opend the panel. else
he will be allowed..

any thoughts ?

thx
JK
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top