Urgent Help : help with the code - InfoPath Dev

InfoPath Dev

Use our Google Custom Search for best site search results.

Urgent Help : help with the code

Last post 01-27-2009 11:26 PM by bogdantc. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 01-27-2009 05:27 AM

    • rekha
    • Not Ranked
    • Joined on 01-27-2009
    • Posts 2

    Urgent Help : help with the code

    Hi gurus,

    I am learner in infopath and coding field. one of my HR infopath 2007  form need an data submission . The fields in the form for data submission are


    Emp id

    date from date picker which is in the form

    i want to submit the details to database.I heard it can be done by some webservice.can you please help me with full code how  to do that.

    Sorry as i am very new to this field reason i am asking for  full code in (c#) .

    Need to complete the stuff by tomorrow.

    Thanks in advance


    Rekha reddy







  • 01-27-2009 06:25 AM In reply to

    • rekha
    • Not Ranked
    • Joined on 01-27-2009
    • Posts 2

    Re: Urgent Help : help with the code

    Hi ,

    my bad i have followed that example . i have tried implementing in dummy forms but i have a problem  storing the date field from date picker.

    code for only date

    using System;

    using System.Web;

    using System.Web.Services;

    using System.Web.Services.Protocols;

    using System.Data.SqlClient;

    [WebService(Namespace = "http://tempuri.org/")]

    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

    public class Service : System.Web.Services.WebService


    public struct google



    public string date;


    WebMethod]public int cool(google e)


    int rowsAffected = 0;

    using (SqlConnection conn = new SqlConnection("Data Source=MMSTIER2;Initial Catalog=Efforts;Integrated Security = SSPI;"))


    SqlCommand cmd = new SqlCommand("INSERT INTO dummy(date) VALUES (@date)", conn);





    rowsAffected = cmd.ExecuteNonQuery();


    return rowsAffected;



    sql server  column is

    date datetime

    when i execute  and run it stores the blank value like

    1900-01-01 00:00:00.000

    date is  from the datepicker format  is 1/27/2009

    can you please help me with date .so that i can combine everything for final form and  submit.

    i fear i may spoil the main form reason i am trying in dummy forms.




  • 01-27-2009 11:26 PM In reply to

    • bogdantc
    • Not Ranked
    • Joined on 05-27-2008
    • Bucharest
    • Posts 25

    Re: Urgent Help : help with the code


    This is a very fast code creation and there could be some data types minor mistakes. If there are please accept my apologies.  You can create a "Hello world!" web service in C# and then you have to create another method SetEmployeesDetails (see below) which will call a stored procedure to do the actual insert.

    using System.Data.SqlClient;
    using System.Data;

    [WebMethod(Description = "Sets employees details")]
        public int SetEmployeesDetails(string sEmployeeName, int nEmployeeId, DateTime dtDate )
            int inRowsAffected;
            SqlConnection sqlConnSetEmployeesDetails;

            sqlConnSetEmployeesDetails = new SqlConnection("Data Source=myServerName;Initial Catalog=myDataBase;User ID=myUser;Password=myPass;");

            using (sqlConnSetEmployeesDetails)
                SqlCommand sqlCmdSetEmployeesDetails = new SqlCommand("myTableIns", sqlConnSetEmployeesDetails);

    CommandType = CommandType.StoredProcedure;
                sqlCmdSetEmployeesDetails.Parameters.Add(new SqlParameter("@myEmployeeName", SqlDbType.NVarChar, 50));
                sqlCmdSetEmployeesDetails.Parameters[0].Value = sEmployeeName;
                sqlCmdSetEmployeesDetails.Parameters.Add(new SqlParameter("@myId", SqlDbType.Int));
                sqlCmdSetEmployeesDetails.Parameters[1].Value = nEmployeeId;
                sqlCmdSetEmployeesDetails.Parameters.Add(new SqlParameter("@myDate", SqlDbType.Datetime));
                sqlCmdSetEmployeesDetails.Parameters[2].Value = dtDate;

                inRowsAffected = sqlCmdSetEmployeesDetails.ExecuteNonQuery();

            return inRowsAffected;

    I really hope you will manage to make this code work. Please let me know of your final result.

    Have fun,
    Able was I ere I saw Elba
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.