problem in Submitting data from infopath form to sql server via programming - InfoPath Dev
in

InfoPath Dev

problem in Submitting data from infopath form to sql server via programming

Last post 09-15-2009 02:35 AM by Kshitij bishnoi24. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 09-11-2009 09:36 AM

    problem in Submitting data from infopath form to sql server via programming

    Hi! 

    i have make one form and write code for submitting the data to sql server ,by given full trust it is submitting the data to sql but  once i published this form and activate this form as a feature in sharepoint site and open the form in browser it is not showing any error and not submitting anything to sql server ....

    Can anybody help me ,its urgent...

     

    thanks,

    kshitij  

  • 09-13-2009 06:55 AM In reply to

    Re: problem in Submitting data from infopath form to sql server via programming

    Do you have any errors in the design checker? What is your code like? I'm wondering if it is a security issue -- you might be better off creating a UDC for the data connection, then modifying the connection's command in code to an insert command. I think this will keep you from having to make your form full trust, as well.

    Hilary Stoupa

  • 09-14-2009 02:45 AM In reply to

    Re: problem in Submitting data from infopath form to sql server via programming

    Hi!

    thanx for ur reply , no errors in design checker .

    code what i have written is :

    SqlConnection conn = null;

    try

    {

    XPathNavigator navigator =
    this.MainDataSource.CreateNavigator();

    string Title = navigator.SelectSingleNode("//my:title", this.NamespaceManager).Value;

    string Address = navigator.SelectSingleNode("//my:address", this.NamespaceManager).Value;

    string City = navigator.SelectSingleNode("//my:city", this.NamespaceManager).Value;

    string State = navigator.SelectSingleNode("//my:state", this.NamespaceManager).Value;

    string Zipcode = navigator.SelectSingleNode("//my:zipcode", this.NamespaceManager).Value;

    double Latitude = Convert.ToDouble(navigator.SelectSingleNode("//my:latitude", this.NamespaceManager).Value);

    double Longitude = Convert.ToDouble(navigator.SelectSingleNode("//my:longitude", this.NamespaceManager).Value);

    conn = new SqlConnection();conn.ConnectionString = "server=KFLS3;database=FCS;Trusted_Connection=yes";

    conn.Open();

    SqlCommand command =
    new SqlCommand();

    command.Connection = conn;

    command.CommandText = "INSERT INTO FCS_DEMO VALUES ('" + Title + "','" + Address + "','" + City + "','" + State +

    "','" + Zipcode + "','" + Latitude + "','" + Longitude + "')";

    command.ExecuteNonQuery();

    }

    catch (Exception ex)

    {

    }

    finally

    {

    conn.Close();

    }

     

    i am new to infopath coding can u please elaborate about UDC in infopath .. or what i have did wrong in my coding... 

    Regards,

    kshitij  

     

  • 09-14-2009 05:16 PM In reply to

    Re: problem in Submitting data from infopath form to sql server via programming

    Your code works in the client? Just not on the browser?

    Hilary Stoupa

  • 09-15-2009 02:35 AM In reply to

    Re: problem in Submitting data from infopath form to sql server via programming

     yes .. how to make it browser compatible code...

Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.