infopath 2007 submit data via web service to sql 2008

Posted on 2008-11-19
Last Modified: 2012-05-05
I am trying to submit data from an infopath 2007 form to an sql 2008 database table named "employees".  I have 5 columns in the table which i want populated when the user pushes the submit button on the form.  I made a web service to help with the data transfer which infopath connects to.  the problem i have is that when i push the submit button, i get an error on the form telling me  the following.  After the infopath error message, I have included my web service code. i would appreciate some direction in what i am doing wrong.  thank you.

The query cannot be run for the following DataObject: AddNewEmployee
InfoPath cannot run the specified query.
The SOAP response indicates that an error occurred:

System.Web.Services.Protocols.SoapException: Server was unable to read request. ---> System.InvalidOperationException: There is an error in XML document (1, 424). ---> System.FormatException: Input string was not in a correct format.
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
   at System.Xml.XmlConvert.ToInt32(String s)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read2_Employee(Boolean checkType)
   at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read3_AddNewEmployee()
   at Microsoft.Xml.Serialization.GeneratedAssembly.ArrayOfObjectSerializer.Deserialize(XmlSerializationReader reader)
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
   --- End of inner exception stack trace ---
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle)
   at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
   --- End of inner exception stack trace ---
   at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
   at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()


 using System;
 using System.Web;
 using System.Web.Services;
 using System.Data;
 using System.Data.SqlClient;

public class Service : System.Web.Services.WebService
    public struct Employee
        public int EmployeeNumber;
        public String Title;
        public String FirstName;
        public String LastName;
        public Decimal Salary;

    public int AddNewEmployee(Employee employee)
  int rowsAffected = 0;
  using (SqlConnection conn = new SqlConnection("Data Source=(local);Initial Catalog=Online_Content;User ID=user;Password=******"))
    SqlCommand cmd = new SqlCommand("INSERT INTO Employees " +
      "(EmployeeNumber, Title, FirstName, LastName, Salary) " +
      "VALUES(@EmployeeNumber, @Title, @FirstName, @LastName, @Salary)", conn);

    cmd.Parameters.AddWithValue("@EmployeeNumber", employee.EmployeeNumber);
    cmd.Parameters.AddWithValue("@Title", employee.Title);
    cmd.Parameters.AddWithValue("@FirstName", employee.FirstName);
    cmd.Parameters.AddWithValue("@LastName", employee.LastName);
    cmd.Parameters.AddWithValue("@Salary", employee.Salary);

    rowsAffected = cmd.ExecuteNonQuery();

  return rowsAffected;
Question by:bwierwi
    1 Comment
    LVL 28

    Accepted Solution

    It is way simpler to get the web services prebuilt.

    I would download the free suite from Qdabra, even just to test it and see how they do it.

    Personally it is way simpler and easier since then trying to build one yourself that does everything theirs does.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    This is basically a blog post I wrote recently. I've found that SARGability is poorly understood, and since many people don't read blogs, I figured I'd post it here as an article. SARGable is an adjective in SQL that means that an item can be fou…
    Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now