Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't retrieve data with dot symbol from sql database
    primarykey
    data
    text
    <p>In my project (vb.net) I store the ip address of a website in a table with column of type <code>nvarchar</code>. But I can't retrieve it from the table. I wonder if its a problem with "dot" symbol. Please help.</p> <p>This is the command that I use</p> <pre><code> query = "select *from restricted_sites where site_address='" + webip + "'" </code></pre> <p><code>webip</code> is the ip address of web site.</p> <p><code></p> <pre><code>Imports System.Data.SqlClient Imports System.Net Public Class restrict Private Sub clear_button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clear_button.Click site_TextBox1.Text = "" addr_TextBox1.Text = "" End Sub Private Sub submit_button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles submit_button.Click Dim connectionstr As String Dim query As String Dim conn As SqlConnection Dim cmd As SqlCommand Dim webip As String Dim hostname As IPHostEntry = Dns.GetHostByName(addr_TextBox1.Text) Dim ip As IPAddress() = hostname.AddressList Try webip = ip(0).ToString connectionstr = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\URLTrack.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True" conn = New SqlConnection(connectionstr) conn.Open() query = "insert into restricted_sites values('" + site_TextBox1.Text + "','" + webip + "')" cmd = New SqlCommand(query, conn) cmd.ExecuteNonQuery() MsgBox("Website added for restriction", MsgBoxStyle.Information) conn.Close() Catch ex As SqlException End Try End Sub End Class </code></pre> <p></code></p> <pre><code>Private Sub Combox1_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Combox1.KeyPress If e.KeyChar = Convert.ToChar(Keys.Enter) Then Dim connectionstr As String Dim query As String Dim cmd As SqlCommand Dim reader As SqlDataReader Dim conn As SqlConnection Dim url As String = "" Dim webip As String Dim hostname As IPHostEntry = Dns.GetHostByName(Combox1.Text) Dim ip As IPAddress() = hostname.AddressList webip = ip(0).ToString connectionstr = "Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\URLTrack.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True" conn = New SqlConnection(connectionstr) conn.Open() query = "select * from restricted_sites where site_address='" + webip + "'" cmd = New SqlCommand(query, conn) reader = cmd.ExecuteReader While (reader.Read()) url = reader(2) End While reader.Close() MsgBox(url, MsgBoxStyle.Information) If webip &lt;&gt; url Then AxWebBrowser1.Navigate(Combox1.Text) Combox1.Text = AxWebBrowser1.LocationURL Else MsgBox("This Web Page is Restricted.Contact the ADMIN for Further Info", MsgBoxStyle.Critical) End If End If If e.KeyChar = Convert.ToChar(Keys.Escape) Then AxWebBrowser1.Stop() End If End Sub </code></pre> <p>The second code is the comparing part. query = "select * from restricted_sites where site_address='" + webip + "'" this code is the problem. This is my code for restricting web sites through matching with ip address stored in database,when the url is being navigated.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload