infopath 2007 submit data via web service to sql 2008

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;
Who is Participating?
Clay FoxConnect With a Mentor Director of Business IntegrationCommented:
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.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.