Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Clarification With Sql like command

Author  Topic 

balajiie
Starting Member

7 Posts

Posted - 2010-01-28 : 08:33:27
Hi All,
I am Beginner in Sql..

here is ma code

SqlConnection sqlc = new SqlConnection(sConnectionString);
SqlCommand sqlcomm;
SqlDataAdapter sqlData;
try
{
sqlc.Open();
string strSelectNotBySearch = "select * from OP_Notification where Subject like @Subject and Deleted=0";
sqlcomm = new SqlCommand(strSelectNotBySearch, sqlc);
sqlcomm.Parameters.Add("@Subject", SqlDbType.NVarChar, 128).Value = strSub;
sqlData = new SqlDataAdapter(sqlcomm);
DataTable dt = new DataTable();
sqlData.Fill(dt);
return dt;
}
catch
{
throw;
}
finally
{
if (sqlc.State == ConnectionState.Open)
sqlc.Close();
}
I need To Get value Like Parameters @Subject

do Reply

All is well
Balaji

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2010-01-28 : 08:57:49
try this

where Subject like "'%" + @Subject +"%' and Deleted=0

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

balajiie
Starting Member

7 Posts

Posted - 2010-01-29 : 04:02:13
Hi Jim

First of all Thank for your Reply

But its not working

Showing some error in the Query itself

I Think There is some problem with the single quotes and double quotes

do Reply

All is well
Balaji
Go to Top of Page

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2010-01-29 : 07:26:42
What error do you get? Also, could you post strSelectNotBySearch so we can see the exactly what the query looks like?

Thanks,

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page

balajiie
Starting Member

7 Posts

Posted - 2010-01-29 : 23:05:57
hi Jim

I already Posted Tha Query strSelectNotBySearch above

All is well
Balaji
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-01-30 : 00:20:41
i dont think there's any problem with query. can you try running the below query in query analyser?

select * from OP_Notification where Subject like "'%" + @Subject +"%' and Deleted=0
Go to Top of Page
   

- Advertisement -