troubleshooting Question

ExecuteScalar() issue in

Avatar of tattsnyc
tattsnyc asked on
9 Comments1 Solution2246 ViewsLast Modified:
This problem wil ldrive me to drink .I am working on a web page  in . I want to use  executescalar() to  execute a stored procedure which wil lreturn one value of 1. I then want to say if the executescalar =1 then do this else do that .It doesnt seem to woirk the same as so I am lost and have spent many hours trying to figure this out.  I get the following error currently:

c:\inetpub\wwwroot\WebInvoice\Invoice.aspx.cs(126): Cannot implicitly convert type 'object' to 'bool'

No matter what ,Howevber, I get some kind of error while debugging.  Please advise ASAP. Thanks in advanmce for your help and time.  Bellow is the code for the Stored Procedure and also some Page code.

Stored Procedure:
@Inv Nvarchar(20),
@Cust Nvarchar(20)

Drop Table OnlineInvoiceCK

Select Distinct count(invoice) as Count
Into OnlineInvoiceCK
FROM ARSalesHeader

where (@cust=ARSalesHeader.CustomerID) And (Invoice = @Inv)

Page Code:

                        SqlConnection ConnCK = new SqlConnection
                                                                   ("Server=Apps1;Database=ChainDynamics;User ID=sa;Trusted_Connection=False" );
                        SqlCommand CmdCK = new SqlCommand("AAAInvoiceAspxReportCK",ConnCK);
                        CmdCK.CommandType = CommandType.StoredProcedure;
                        SqlParameter invCK = new SqlParameter("@Inv", SqlDbType.NVarChar,20);
                        invCK.Direction = ParameterDirection.Input;
                        invCK.Value = Request.QueryString["inv"];
                        SqlParameter custCK = new SqlParameter("@Cust", SqlDbType.NVarChar,20);
                        custCK.Direction = ParameterDirection.Input;
                        custCK.Value = Session["LogonID"];
                              object correct = new object();
                              object a = new object();
                    correct = CmdCK.ExecuteScalar();
                              if(correct =a)

                                //Page code }

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 9 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros