The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
Executing a stored procedure
Posted: 11 May 10 5:13 AM
|
Hi All,
Could someone explain, or show the format of the code, needed to execute a stored procedure in 7.5 web.
I have the Opportunity Details form open in Visual Studio and ive added a link next to the Copy Info to Email link that will exeute a stored procedure in the database. |
|
|
|
Re: Executing a stored procedure
Posted: 11 May 10 5:23 AM
|
p.s this is how i did it in 7.2:
Set cn = CreateObject("ADODB.Connection") cn.Open Application.GetNewConnection
set cnCmd=CreateObject("ADODB.Command") cnCmd.ActiveConnection = cn cnCmd.CommandType = 4 cnCmd.CommandText = "ZSP_ACH_CREATE_PROJECT" cnCmd.NamedParameters = True
set cnParam=cnCmd.CreateParameter("@slx_key",200,1,12,Application.BasicFunctions.CurrentOpportunityID) cnCmd.Parameters.Append cnParam
set cnInt = cnCmd.Execute cn.Close 'close connection
set cn=nothing 'set connection object = nothing set cnCmd=nothing 'set command object = nothing |
|
|
| |
|
Re: Executing a stored procedure
Posted: 11 May 10 5:38 AM
|
very slowly getting there line by line 
System.Data.OleDb.OleDbCommand copy = new System.Data.OleDb.OleDbCommand(); copy.CommandType = System.Data.CommandType.StoredProcedure; copy.CommandText = "ZSP_ACH_CREATE_PROJECT";
just need to figure out how to do the parameters.
Thanks Nick. |
|
|
|
Re: Executing a stored procedure
Posted: 12 May 10 3:33 AM
|
Try this. I'm using a OleDbDataAdapter here but you can just carry out the required action from the command object (command.ExecuteScalar(); etc)
using (System.Data.OleDb.OleDbConnection conn = new System.Data.OleDb.OleDbConnection(connectionString)) { conn.Open(); using (System.Data.OleDb.OleDbCommand cmd = new System.Data.OleDb.OleDbCommand()) { try { cmd.Connection = conn; cmd.CommandText = "up_GetUsersContactGroups"; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@userid", userid);
System.Data.OleDb.OleDbDataAdapter da = new System.Data.OleDb.OleDbDataAdapter(cmd); da.Fill(result); } catch (Exception ex) { throw new Exception(ex.Message); } finally { conn.Close(); } } }
|
|
|
| |
|