Hi,
Make a stored procedure in SQL Server for example:
Create Procedure FindString(<br />
@MyString nvarchar(50))<br />
As<br />
Begin<br />
Select * From MyTable<br />
Where Value = @MyString<br />
End
Make a Class in .NET For example :
public class ReadData
{
public bool FindString(string myString)
{
SqlConnection connection = new SqlConnection();
connection.ConnectionString = "Server=...";
SqlCommand command = new SqlCommand();
command.Connection = connection;
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "FindString";
command.Parameters.AddWithValue("@MyString", myString);
try
{
connection.Open();
SqlDataReader reader = command.ExecuteReader();
while (reader.Read())
{
return true;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
if (connection.State == ConnectionState.Open)
connection.Close();
}
return false;
}
}
Use the class. for example :
ReadData r = new ReadData();
if (r.FindString("Shahingg"))
MessageBox.Show("I Found it!");
else
MessageBox.Show("I can't Find it!");
Do not forget that you need below namespaces for your Class :
using System.Data.SqlClient;
using System.Data;
Good Luck