Not able to insert multi rows from InfoPath to SQL Server using WebServices - InfoPath Dev
in

InfoPath Dev

Not able to insert multi rows from InfoPath to SQL Server using WebServices

Last post 01-10-2011 07:44 AM by Patrick Halstead. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 01-10-2011 06:34 AM

    Not able to insert multi rows from InfoPath to SQL Server using WebServices

    Hi

     I Have created WS which get and update SQL Server DB , and i have created InfoPath form to connect to this web service.

     Now everything is working fine and no errors , but when i click submit only the first row in the repeating section is updated in the Database and others are ignored.

     Anyone having idea what could be the problem?

  • 01-10-2011 06:40 AM In reply to

    Re: Not able to insert multi rows from InfoPath to SQL Server using WebServices

    Hi Amigo1982 and welcome,

    Does your Web Service take the entire XML or just a parameter? To pass it a repeating structure may require passing the entire string to the WS and having it map it to SQL. Qdabra Software, sponsor of this site, provides a database Web Service called DBXL that allows you to set up a mapping like this. It supports arbitrarily deep mappings to SQL. Go to Qdabra.com->Products and try a free trial download. It will save you time and money.

    Patrick Halstead
    Project Manager at Qdabra
  • 01-10-2011 06:52 AM In reply to

    Re: Not able to insert multi rows from InfoPath to SQL Server using WebServices

    Hi Patrick

    Thanks for your quick reply, i m passing it as just parameter here is the code of my WS, its calling my stored procedure and inserting one record only which it is the first record in the repeating section in my InfoPath and stop, do i need to do loop here or do anything in InfoPath?

    [WebMethod]
        public bool UpdateHREducation(String EmplID, String Education, String Desc, DateTime StartDate, DateTime EndDate)
        {
            string strCommandText = "dbo.ALS_spUpdateHREducation";

            using (SqlConnection conn = new
            SqlConnection("server=10.0.11.47 ;database=DynamicsAX1;uid=info;pwd=info123456"))
            {
                SqlCommand cmd = new SqlCommand(strCommandText, conn);
                cmd.CommandType = CommandType.StoredProcedure;
                SqlParameter paramEmplID = new SqlParameter("@EMPLID", SqlDbType.NVarChar);
                paramEmplID.Value = EmplID;
                cmd.Parameters.Add(paramEmplID);
                SqlParameter paramEdu = new SqlParameter("@Education", SqlDbType.NVarChar);
                paramEdu.Value = Education;
                cmd.Parameters.Add(paramEdu);
                SqlParameter paramDesc = new SqlParameter("@Desc", SqlDbType.NVarChar);
                paramDesc.Value = Desc;
                cmd.Parameters.Add(paramDesc);
                SqlParameter paramStartDate = new SqlParameter("@StartDate", SqlDbType.DateTime);
                paramStartDate.Value = StartDate;
                cmd.Parameters.Add(paramStartDate);
                SqlParameter paramEndDate = new SqlParameter("@EndDate", SqlDbType.DateTime);
                paramEndDate.Value = EndDate;
               

                conn.Open();
              

                int i = 0;
                i = cmd.ExecuteNonQuery();
                conn.Close();
                if (i > 0)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }

     

  • 01-10-2011 07:44 AM In reply to

    Re: Not able to insert multi rows from InfoPath to SQL Server using WebServices

    Dude, that code doesn't add more than one so it won't work for repeating. This is a lot more difficult than you think. It's the reason we developed a Web Service back in 2004 that does this for arbitrarily deep repeating XML structures. It's not something you can code up in a day or two. Think about it.

    Patrick Halstead
    Project Manager at Qdabra
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.