i have managed to run the asp file in the local network however it add only my ip each time the users run the file
how can i change the code so that i get the user's ip address not mine
i guess it has something to do with the host.
Code:<%@ Page Language="VB"%> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.OleDb" %> <script language="VB" runat="server"> ' Declared outside the subs so both can access it. Dim objConnection As OleDbConnection Dim h As System.Net.IPHostEntry = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName) Dim value As String = h.AddressList.GetValue(0).ToString() Dim ipfull As String = h.AddressList.GetValue(0).ToString Dim ipsplit() As String = ipfull.Split(".".ToCharArray()) 'IP.Text = h.AddressList.GetValue(0).ToString() Sub Page_Load(ByVal Sender As Object, ByVal E As EventArgs) ' Set up our connection. objConnection = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("ip.mdb") & ";") ' Every call to the page adds a new record and ' shows the data in the table. AddNewRecord() 'ShowDataGrid() End Sub Sub AddNewRecord() Dim objCommand As OleDbCommand Dim strSQLQuery As String ' Our insert command strSQLQuery = "INSERT INTO ip " _ & "(pcname, username, mip) " _ & "VALUES (@TextValue, @TextValue2, @TextValue3)" ' Create new command object passing it our SQL insert ' and telling it which connection to use. objCommand = New OleDbCommand(strSQLQuery, objConnection) ' Add parameters that our SQL command takes: objCommand.Parameters.Add(New OleDbParameter("@TextValue", OleDbType.VarChar, 255)) objCommand.Parameters.Add(New OleDbParameter("@TextValue2", OleDbType.VarChar, 255)) objCommand.Parameters.Add(New OleDbParameter("@TextValue3", OleDbType.VarChar, 255)) objCommand.Parameters("@TextValue").Value = System.Environment.MachineName objCommand.Parameters("@TextValue2").Value = System.Environment.UserName objCommand.Parameters("@TextValue3").Value = ipsplit(3) ' Open the connection, execute the command, and close the connection. Try objConnection.Open() objCommand.ExecuteNonQuery() objConnection.Close() status.Text = "data added" Catch ex As Exception status.Text = "you can add data only once" End Try End Sub </script> <html> <body> <form id="form1" runat="server"> <asp:Label ID="Label1" runat="server" Text="Status"></asp:Label> <asp:TextBox ID="status" runat="server" Width="352px"></asp:TextBox><!-- Plain old DataGrid... format it as you like. --> </form> </body> </html>




Reply With Quote