Using stored procedure in code - InfoPath Dev

InfoPath Dev

Use our Google Custom Search for best site search results.

Using stored procedure in code

Last post 03-04-2009 07:22 AM by belote82. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 10-21-2008 01:08 AM

    Using stored procedure in code


    I have to add some data in a sql table when the user press a button.

    I think I have to do this programmatically.

    So I've tried to use ADO connection, but it doesn't work...

     That's what I've done :

    Dim mConnection Set mConnection = CreateObject("ADODB.Connection")

    mConnection.Open "Provider=SQLOLEDB.1;Data Source=SRVTRAD1\INSD01;Initial Catalog=EL1EEDPCentre;Integrated security=SSPI" mConnection.Open "server=SRVTRAD1\INSD01;database=EL1EEDPCentre;Integrated Security=SSPI;"

    result = mConnection.Execute("EXECUTE IC.prc_LapWeb_Insert @bookEmpID = " & fldMatricule & ", @bookEmail = " & fldEmail & ", @bookBegin = " & fldBegindate & ", @bookEnd = " & fldEnddate & ", @bookType = " & fldHardwaretype & ", @Comment = " & fldComment & ", @Status = 1")

    At the MConnection.Open, Ive this message : safety settings on this computer prohibit accessing a data source on another domain

     Where am I wrong? Is there another way to do this?

    Thank you very much




  • 10-21-2008 06:43 AM In reply to

    Re: Using stored procedure in code

    Hi,Make sure that you have permissions to access the data base. And also make sure that the form should be a full trust form. To make  a form full trust, follow the below steps.1.    Go to tools->form options2.    In the security and trust tab, uncheck ‘Automatically determine security..’ and select ‘Full Trust(..)’ radio button. Click ok.


  • 10-21-2008 07:00 AM In reply to

    Re: Using stored procedure in code

    I've all the permissions and my form is in full trust...

     I really don't understand the problem.


    I've also tried to make a dataconnection with a "Select ..." , change the command of the queryadapter in the code to "execute ..." and use the myAdapter.Query().

    I've no error, but no row have been added to my table...

     I'm desperate...


  • 10-21-2008 11:03 PM In reply to

    Re: Using stored procedure in code

    Once use the following code. Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim cmd As New SqlCommand("spInsertData", New SqlConnection(ConfigurationManager.AppSettings("ConnString")))
    cmd.CommandType = CommandType.StoredProcedure

    cmd.Parameters.AddWithValue("@name", txtName.Text)
    cmd.Parameters.AddWithValue("@city", txtCity.Text)

      The Stored Procedure will look something like this:ALTER PROCEDURE spInsertData @name varchar(50),
    @city varchar (50)
    AS INSERT INTO [tblOne]
    (theName, theCity)
    VALUES (@name, @city)


  • 10-22-2008 12:29 AM In reply to

    Re: Using stored procedure in code

    I've not said that I'm using vbscript or Jscript, but no .NET code...

     But thanks for your reply

  • 03-04-2009 06:04 AM In reply to

    Re: Using stored procedure in code

    I've the problem again, I have to use an insert stored procedure


    Any idea how to do this??


    Please, help :)

  • 03-04-2009 06:40 AM In reply to

    Re: Using stored procedure in code


     I have had to use a stored proceedure recently and found Hilary Stoupa's post on "Fun with Sequential Form IDs, SQL and Sprocs!" a real hair saver.

    If you look at all the steps involved it should help you out.

    I was particularly helped by the addendum at the bottom, be sure to read the whole blog post.

    (Thank you Hilary!)





  • 03-04-2009 07:22 AM In reply to

    Re: Using stored procedure in code

    It works

     thank you so much!!

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