473,463 Members | 1,536 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

compare value of variable with all values in a sql server08 table column using c#

Hello , i want to compare a value of a variable with all the values in a table column c# and sql server08. if this value is in column do nothing , if it is in the column do sth .. please help me for my project!! what to use :/
May 26 '13 #1
7 2382
Oralloy
988 Expert 512MB
thomaaxha,

What have you done on this problem to help yourself?

Obviously you will have to use SQL under C#, now what?

Oralloy
May 26 '13 #2
ok i did it , but i have to find if a variable value exist in a table column or not
May 26 '13 #3
vijay6
158 100+
Hey thomaaxha, you can use SQL COUNT() Function. Like this,

Expand|Select|Wrap|Line Numbers
  1. SELECT COUNT[Column_name(s)] FROM [Table_name] WHERE [Condition]

After this check count value, if it is > 0 then value already exists in table else not exists.
May 27 '13 #4
I am gonna try this ,, :) .. thnx
May 27 '13 #5
[Column_name(s)] --> what do you refer with (s)???
May 27 '13 #6
i have this problem:

Expand|Select|Wrap|Line Numbers
  1. string gjejip = "SELECT COUNT (*) FROM [Table_ip] WHERE [IP_votuesit = '" + ip + "']";
  2.                 SqlCommand cmdFutIp = new SqlCommand(gjejip, con);
  3.                 string gjejip1 = cmdFutIp.ExecuteScalar().ToString();
  4.                 Label8.Text = gjejip1;

the error is: An expression of non-boolean type specified in a context where a condition is expected, near 'IP_votuesit = '127.0.0.1''.
May 27 '13 #7
vijay6
158 100+
[Column_name(s)] --> what do you refer with (s)???
General syntax of select query.

Hey thomaaxha, in your code remove those square brackets '[' and ']' (which you used for where condition) and try...
May 28 '13 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Martin Lucas-Smith | last post by:
Can anyone point me to a regular expression in PHP which could be used to check that a proposed (My)SQL database/table/column name is valid, i.e. shouldn't result in an SQL error when created? ...
1
by: chelleybabyger | last post by:
Using the below method, <% remaining_stock = cint(product_stock) - cint(chQuantity) %> <% sqlString = "UPDATE Products SET " &_ "product_stock='" & remaining_stock & "'," &_ "WHERE...
5
by: Robert | last post by:
Does anybody have the code for, an example of, or a link to a text-search function that supports exact phrase, any word, and all words searching in an Access table. If so, could you please post it?...
1
by: VMI | last post by:
How can I sort a table column correctly when the table has values like "0", "A1", "AA-1", "B21", "3C", 4-32A", "1", "11-1", 2-A", etc... The table will then be loaded to a grid and that's when...
4
by: Scot L. Harris | last post by:
Currently using Postgresql 7.2.4-5.80 with php 4.2.2.-8.0.8 on a redhat 8.0 system. I am writing some php scripts where I want to generate a list of the column names in a particular table that...
2
by: ipy2006 | last post by:
How can I filter a dynamically created table with some search criteria. Are there any examples any where for this. Here is what I am looking for, Table Column A Column B Column C a1 ...
1
by: jane2007 | last post by:
Hello, Here is my current code ... Dim rstStk As Recordset Set rstStk = CurrentDb.OpenRecordset("Select * from stk where PartNum = '" & strPrt & "'") The problem with this code is that i...
8
by: mguy27 | last post by:
We have about 2 dozen security officers who patrol about 120 buildings. They find defective or unlocked doors and write a "Trouble Report" on the door. This card gets turned in, where I have designed...
1
by: abinesh.agarwal | last post by:
Hi , I want to update the column in a table based on the updation of the other column in the same table, but not getting the desired result. DDL: CREATE TABLE .( NULL,
2
by: Pradeep23 | last post by:
Hi all, I want to export 1 big excel workbook containing 200 Sheets in it, and is classified according to Class. Each sheet name is unique according to the class. I am building a package to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.