Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7811179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:03:59+00:00 2026-06-02T04:03:59+00:00

My code checks for changes in the database and then sends an update via

  • 0

My code checks for changes in the database and then sends an update via a web service to the client.

I had the part sending the message to the client working fine because making the calls to check for changes in the database. Now that I have added the portion checking database changes I am getting the following error.

When Debugging my code the error points at the exception at the very bottom of the code so I have no idea where the error is coming from and no way of fixing it.

Any advise would be greatly appreciated

    SendInvUpdate.InvServices.UpdateRatePackagesRequest ur = new SendInvUpdate.InvServices.UpdateRatePackagesRequest();
    SendInvUpdate.InvServices.UpdateRatePackagesOperationResponse or = new SendInvUpdate.InvServices.UpdateRatePackagesOperationResponse();


    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            string connStr = ConfigurationManager.ConnectionStrings["bb"].ConnectionString;
            SqlConnection Con = new SqlConnection(connStr);
            Con.Open();
            SqlCommand cmd = new SqlCommand("invpush_PollForAvailableChanges", Con);
            cmd.CommandType = CommandType.StoredProcedure;
            SqlParameter NewSysChangeVersionParam = new SqlParameter("@NewSysChangeVersion", SqlDbType.Int);
            NewSysChangeVersionParam.Value = (object)NewSysChangeVersionParam ?? DBNull.Value;
            NewSysChangeVersionParam.Direction = ParameterDirection.InputOutput;
            NewSysChangeVersionParam.SqlDbType = SqlDbType.BigInt;
            SqlDataReader sdr = cmd.ExecuteReader();

            InventoryPushSubscriptionRecord rec = new InventoryPushSubscriptionRecord();

            while (sdr.Read())
            {

                rec.InventoryPushSubId = sdr.GetInt32(0);
                rec.CMName = sdr.GetString(1);
                rec.NotifUrl = sdr.GetString(2);
                rec.Options = sdr.GetString(3);
                rec.LastSysChangeVersion = sdr.IsDBNull(4)?(long?)null:sdr.GetInt32(4);

            }

            if(!sdr.NextResult()) throw new System.Exception("Expected Result set 1 for InventoryChangeRecord");
            InventoryChangeRecord inrec = new InventoryChangeRecord();
            while (sdr.Read())
            {
                inrec.InventoryPushSubId= sdr.GetInt32(0);
                inrec.SysChangeVersion=sdr.IsDBNull(1)?(long?)null:sdr.GetInt32(1);
                inrec.InvDate=sdr.GetDateTime(2);
                inrec.ResId=sdr.GetInt32(3);
                inrec.RoomType=sdr.GetString(4);
                inrec.InvCount=sdr.GetInt32(5);
                inrec.ResName=sdr.GetString(6);

            }

            sdr.Close();
            sdr.Dispose();

            if (NewSysChangeVersionParam != null)
            {
                int ResId;
                Int64 ResoId;
                ResortId = inrec.ResId;
                SqlDataAdapter sda = new SqlDataAdapter("Select BID,RId from BBTest.bbtest.tblResMapping where BId=@ResId",Con);
                SqlParameter resId = new SqlParameter("@ResId", ResId);
                sda.SelectCommand.Parameters.Add(resId);
                DataSet ds = new DataSet();
                sda.Fill(ds, "tblresmapping");
                if (ds.Tables[0].Rows.Count > 0)
                {
                    ResoId = Convert.ToInt32(ds.Tables[0].Rows[0]["ResonlineId"]);
                }

                if (ds.Tables[0].Rows.Count != 0)
                {
                    Int64 RatePackageId;
                    SqlDataAdapter sqlda = new SqlDataAdapter("Select BId,BBRoom,ResRatePackageID from tblResRatePackages where BID =@ResortId", Con);
                    SqlParameter resI = new SqlParameter("@RId", resId);
                    sqlda.SelectCommand.Parameters.Add(resI);
                    DataSet dt = new DataSet();
                    sqlda.Fill(dt, "tblResRatePackages");
                    if (dt.Tables[0].Rows.Count > 0)
                    {
                        RatePackageId = Convert.ToInt64(dt.Tables[0].Rows[0]["ResRatePackageID"]);

                        Int64 HID = ResId;
                        Int64 HRID = RatePackageId;

                        SendInvUpdate.InvServices.UpdateRatePackagesRequest request = new SendInvUpdate.InvServices.UpdateRatePackagesRequest();


                        request.HotelId = account.HotelId;

                        int avail = inrec.InvCount;
                        DateTime frodte = inrec.InvDate;

                        int NoofRatePackages = 3;
                        UpdateRatePackageRequest[] RatePackages = new UpdateRatePackageRequest[NoofRatePackages];
                        string res;
                        request.RatePackages = new UpdateRatePackageRequest[NoofRatePackages];
                        request.RatePackages = RatePackages;

                        for (int i = 0; i < NoofRatePackages; i++)
                        {
                            UpdateRatePackageRequest rp = new UpdateRatePackageRequest();

                            request.RatePackages[i] = rp;

                            rp.RatePackageId = HRID;

                            rp.Rates = new RateDetails[NoofRatePackages];

                            for (int j = 0; j < NoofRatePackages; j++)
                            {

                                RateDetails rd = new RateDetails();
                                rp.Rates[j] = rd;

                                rd.Availability = avail;

                                rd.AvailabilityApplicationType = SendInvUpdate.InvServices.AvailabilityApplicationType.SET;

                                rd.FromDate = frodte;

                          //      rd.ToDate = todte;

                            }

                        }

                        SendInvUpdate.InvServices.InventoryServiceClient isc = new SendInvUpdate.InvServices.InventoryServiceClient();
                        or = isc.UpdateRatePackages(request);


                        res = or.Results.ToString();


                    }

                }
            }                             

        }

        catch (Exception ex)
        {
            throw (ex);
        }
    }

}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T04:04:00+00:00Added an answer on June 2, 2026 at 4:04 am

    One thing to try: Set a breakpoint right at the start of the try-catch block, on the connStr = line, and step through the code line by line, progressing over method calls. In this way you can quickly track down which part of the code is throwing the error, and then home in on that point to look for the specific problem. (You will also be able to read the original exception and innerexception messages prior to the rethrow.)

    Given the title of your question, so the assumption that the error you are having is a casting exception, the first place I would check would be in your database data retrieval code. You are using sdr.GetInt32(0) for instance, this would throw that sort of error if column 0 couldn’t be converted to an integer.

    Hope this helps. If you are able to track down more information, post it and we’ll see if we can give more specific advice.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Quick question. I got a code below, which checks with a database whether a
This portion of code checks if a number given (First element in a list)
I've got a list of names which some code checks against to see if
Here is my code which checks if the file exists : #include<stdio.h> #include<zlib.h> #include<unistd.h>
So I have this code that checks 4 parameters (author, title, keyword and subject)
I have a code block that checks certain elements before allowing a form to
I have some code that currently checks for minimum and maximum lentgh. I want
I have this code snippet inside a function that checks if an object exists
I have this method which does certain checks and applies a color code on
I have an asp web form which is used for database entry located at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.