January 6, 2008 at 9:13 pm
sqlcmd.Parameters.Clear();
sqlcmd.CommandText = "select Price,PostedFlag from AcqCostBook where SiteId=@SiteId and NDC=@NDC";
sqlcmd.Parameters.Add("@SiteId", SqlDbType.Int).Value = SiteId;
sqlcmd.Parameters.Add("@NDC", SqlDbType.VarChar, 20).Value = NDC.Trim();
SqlDataReader Reader = sqlcmd.ExecuteReader();
if (Reader.HasRows)
{
Reader.Read();
oldPrice = Decimal.Parse(Reader[0].ToString());
if (oldPrice == Price)
PostedFlag = Reader[1].ToString().Trim();
IsEntryAcqbook = true;
}
Reader.Close();
From the above How can i Read the Datas and check the rows
Pls Reply soon
January 7, 2008 at 12:14 am
You can use the System.Diagnostics.Debug object to send value into output windows (or console object if you work with a console project).
Or you can filled in a datatable.
January 7, 2008 at 3:40 am
If you are using the Visual Studio 2005 you can add a watch and check the Rows. On the Quick watch you can check everything that you want.
January 7, 2008 at 3:46 am
I NEED TO CONVERT THIS AS TSQL not in C#
January 7, 2008 at 5:54 am
Use a cursor :
SET NOCOUNT ON
DECLARE @vendor_id int, @vendor_name nvarchar(50),
@message varchar(80), @product nvarchar(50)
PRINT '-------- Vendor Products Report --------'
DECLARE vendor_cursor CURSOR FOR
SELECT VendorID, Name
FROM Purchasing.Vendor
WHERE PreferredVendorStatus = 1
ORDER BY VendorID
OPEN vendor_cursor
FETCH NEXT FROM vendor_cursor
INTO @vendor_id, @vendor_name
WHILE @@FETCH_STATUS = 0
BEGIN
PRINT ' '
SELECT @message = '----- Products From Vendor: ' +
@vendor_name
PRINT @message
-- Declare an inner cursor based
-- on vendor_id from the outer cursor.
DECLARE product_cursor CURSOR FOR
SELECT v.Name
FROM Purchasing.ProductVendor pv, Production.Product v
WHERE pv.ProductID = v.ProductID AND
pv.VendorID = @vendor_id-- Variable value from the outer cursor
OPEN product_cursor
FETCH NEXT FROM product_cursor INTO @product
IF @@FETCH_STATUS <> 0
PRINT ' '
WHILE @@FETCH_STATUS = 0
BEGIN
SELECT @message = ' ' + @product
PRINT @message
FETCH NEXT FROM product_cursor INTO @product
END
CLOSE product_cursor
DEALLOCATE product_cursor
-- Get the next vendor.
FETCH NEXT FROM vendor_cursor
INTO @vendor_id, @vendor_name
END
CLOSE vendor_cursor
DEALLOCATE vendor_cursor
January 7, 2008 at 11:14 pm
You must be carrefull with the cursor, In fact the performance can degrade if you use cursor frequently.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply