Hi,
I want to search my table for a particular value and know if it found it. I
tried the code below, but the ExecuteNonQuery only returns a value of -1 so
it does not tell me whether it found it or not. How can I do a search then
and know if it found the value.
TIA
Roy
using System;
using System.Data;
using System.Data.Common;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Text;
using System.IO;
namespace TestSelect
{
class Program
{
static void Main(string[] args)
{
int XXX = 0;
string strConnection = @"Data
Source=.\SQLEXPRESS;AttachDbFilename=D:\CSRBC\rbc\ dbEnum2BLK.mdf;Integrated
Security=True;Connect Timeout=30;User Instance=True";
string strCommand = "SELECT COUNT(*) FROM tblEnum2BLK WHERE MsPt1_2=2";
SqlConnection oConnection = new SqlConnection(strConnection);
SqlCommand oCommand = new SqlCommand(strCommand, oConnection);
oCommand.Connection.Open();
XXX = oCommand.ExecuteNonQuery();
Console.WriteLine("xxxx {0}", XXX);
Console.ReadLine();
oCommand.Connection.Close();
}
}
}