I need a sql query to match two strings in where clause -


Both 'Html' and 'Blacklist Tables' (two separate tables) have 'IP' text fields. The 'IP' string storage IP address of the existing client. I first want to check if the client's IP address is in the black list and then in the whitelist (if not in the blacklist). Since this string is mailing, '=' operator is not producing the correct result. Also, do not want to use 'like' because I'm looking for exact match instead of pattern.
  string [] ipPort = txtCIP.Text.Split (new four [] {':'}, 2); String IP = IPport [0]; Con.Open (); //MessageBox.Show ("Open connection!"); String query = "SELECT count (*)" from blacklist WHERE IP = ip; SqlCommand CMD = new SQL command (query, conn); int rowCount = 1; rowCount = (int) cmd.ExecuteScalar (); string wlq = "SELECT SELECT (*) Whitelist WHERE IP = ip"; SqlCommand cmd_wl = New SqlCommand (wlq, con); int rowcount_wl; rowcount_wl = (int) cmd_wl.ExecuteScalar (); If (rowcount> 1) {Messagebox.Show ("This IP is black listed. Please try again after a few seconds.");} And if (line line = 1) {message box. Show ("This IP is present in white list.");} Other {Message Box. Show ("IP Whitelist does not exist ");} con.Close ();    

I think The issue that is in your selection, varialbe [ip] should be outside double quote marks,

  string query = "selection number (*) BlackList WHERE from IP = ip" ;;   

should be like this,

  string query = "select count (*) BlackList WHERE IP =" + ip;   

and

  string wlq = "SELECT SELECT (*) whitelist WHERE IP = ip";   

should be like this,

  string wlq = "SELECT SELECT (*) Whitelight WHERE IP =" + ip;    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -