Hello friends suppose I have a table name commitment. That is two field name IsClosed (samll int), IsRejected (small int).
Now I need to run a query that will print "Open" if both (IsClosed & IsRejected) are 0. And will print "Closed" if IsClosed = 1 & IsRejected = 0.And will print "Cancelled" if IsRejected = 1 for each row.
Any help will be really appreciated.
select *,<br />
casewhen IsRejected = 0 and IsClosed =0 then 'Open' <br />
when IsRejected = 0 and IsClosed =1 then 'Closed'<br />
when IsRejected = 1 then 'Canceled'<br />
end as [Status]<br />
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
It is Just One Row value I am Specify, Actually it is generate Dynamicaly"
How Can I Modifying my field through Case When
I want to Modify some field of the Current Row with the Privious row data in my Query
If you're using SQL Server, that won't work unless you create a function and store the value from the previous row. Also you may have trouble defining which is the previous row since typically the rows are coming in random order.
Perhaps you should write a little example with data, what you're trying to achieve.
It would be helpful if you provided a snippet of the actual code so that we could see what you are doing, but my first guess would be that you are executing a query that has a parameter named @Model, but you have not provided a value for that parameter.
I don't believe OledbCommand supports named parameters in a command whose CommandType is CommandText (the default). It expects you to use parameter markers (?) and mostly ignores the name.
If you change
cmd = "INSERT INTO Run(" + field + ") values (" + parameter + ")"
cmd = "INSERT INTO Run(" + field + ") values ( ?,?)"
It should work correctly. Note that because parameter marker tokens are used, theorder in which the parameters are added to the collection becomes critical (must match the order they are actually expected in the statement).
I don't believe OledbCommand supports named parameters
A very good answer (got my 5 ). From the (overlooked) documentation: "The OLE DB.NET Framework Data Provider uses positional parameters that are marked with a question mark (?) instead of named parameters"