473,699 Members | 2,525 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

run stored procedure

How can I run stored procedure (MSSQL) ?
Nov 16 '05 #1
2 5451
using(SqlConnec tion conn = new SqlConnection(< connection string>))
{
SqlCommand cmd = new SqlCommand("MyS PName", conn);
cmd.CommandType = CommandType.Sto redProcedure;
cmd.Paramaters. Add(new SqlParameter(.. .));
conn.Open();
cmd.ExecuteNonQ uery(); // for an SP that doesn't return a result set or scalar value (e.g. count(*))
cmd.ExecuteScal ar(); // for an SP that returns a scalar value
using(SqlDataRe ader r = cmd.ExecuteRead er())// for an SP that returns a result set
{
// process results
}
XmlReader r = cmd.ExecuteXmlR eader(); // for an SP that returns XML
// process XML
}

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

nntp://news.microsoft. com/microsoft.publi c.dotnet.langua ges.csharp/<ez************ *@tk2msftngp13. phx.gbl>

How can I run stored procedure (MSSQL) ?

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.771 / Virus Database: 518 - Release Date: 28/09/2004

[microsoft.publi c.dotnet.langua ges.csharp]
Nov 16 '05 #2
doing this can be even more fun...
check the following out:
you can find it in the Timetracker project (www.asp.net)

*************** *******
//*************** *************** *************** *************** *********

// Microsoft Data Access Application Block for .NET

// http://msdn.microsoft.com/library/en...ml/daab-rm.asp

//

// SQLHelper.cs

//

// This file contains the implementations of the SqlHelper and
SqlHelperParame terCache

// classes.

//

// For more information see the Data Access Application Block Implementation
Overview.

//

//*************** *************** *************** *************** *********

// Copyright (C) 2000-2001 Microsoft Corporation

// All rights reserved.

// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY

// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT

// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR

// FITNESS FOR A PARTICULAR PURPOSE.

//*************** *************** *************** *************** *********

using System;

using System.Data;

using System.Data.Sql Client;

using System.Collecti ons;

namespace ASPNET.StarterK it.Commerce

{

//*************** *************** *************** *************** *********

//

// The SqlHelper class is intended to encapsulate high performance, scalable
best practices for

// common uses of SqlClient.

//

//*************** *************** *************** *************** *********

public sealed class SqlHelper

{

//*************** *************** *************** *************** *********

//

// Since this class provides only static methods, make the default
constructor private to prevent

// instances from being created with "new SqlHelper()".

//

//*************** *************** *************** *************** *********

private SqlHelper() {}

//*************** *************** *************** *************** *********

//

// This method is used to attach array of SqlParameters to a SqlCommand.

//

// This method will assign a value of DbNull to any parameter with a
direction of

// InputOutput and a value of null.

//

// This behavior will prevent default values from being used, but

// this will be the less common case than an intended pure output parameter
(derived as InputOutput)

// where the user provided no input value.

//

// param name="command" The command to which the parameters will be added

// param name="commandPa rameters" an array of SqlParameters tho be added to
command

//

//*************** *************** *************** *************** *********

private static void AttachParameter s(SqlCommand command, SqlParameter[]
commandParamete rs)

{

foreach (SqlParameter p in commandParamete rs)

{

//check for derived output value with no value assigned

if ((p.Direction == ParameterDirect ion.InputOutput ) && (p.Value == null))

{

p.Value = DBNull.Value;

}
command.Paramet ers.Add(p);

}

}

//*************** *************** *************** *************** *********

//

// This method assigns an array of values to an array of SqlParameters.

//

// param name="commandPa rameters" array of SqlParameters to be assigned
values

// param name="parameter Values" array of objects holding the values to be
assigned

//

//*************** *************** *************** *************** *********

private static void AssignParameter Values(SqlParam eter[] commandParamete rs,
object[] parameterValues )

{

if ((commandParame ters == null) || (parameterValue s == null))

{

//do nothing if we get no data

return;

}

// we must have the same number of values as we pave parameters to put them
in

if (commandParamet ers.Length != parameterValues .Length)

{

throw new ArgumentExcepti on("Parameter count does not match Parameter Value
count.");

}

//iterate through the SqlParameters, assigning the values from the
corresponding position in the

//value array

for (int i = 0, j = commandParamete rs.Length; i < j; i++)

{

commandParamete rs[i].Value = parameterValues[i];

}

}

//*************** *************** *************** *************** *********

//

// This method opens (if necessary) and assigns a connection, transaction,
command type and parameters

// to the provided command.

//

// param name="command" the SqlCommand to be prepared

// param name="connectio n" a valid SqlConnection, on which to execute this
command

// param name="transacti on" a valid SqlTransaction, or 'null'

// param name="commandTy pe" the CommandType (stored procedure, text, etc.)

// param name="commandTe xt" the stored procedure name or T-SQL command

// param name="commandPa rameters" an array of SqlParameters to be associated
with the command or 'null' if no parameters are required

//

//*************** *************** *************** *************** *********

private static void PrepareCommand( SqlCommand command, SqlConnection
connection, SqlTransaction transaction, CommandType commandType, string
commandText, SqlParameter[] commandParamete rs)

{

//if the provided connection is not open, we will open it

if (connection.Sta te != ConnectionState .Open)

{

connection.Open ();

}

//associate the connection with the command

command.Connect ion = connection;

//set the command text (stored procedure name or SQL statement)

command.Command Text = commandText;

//if we were provided a transaction, assign it.

if (transaction != null)

{

command.Transac tion = transaction;

}

//set the command type

command.Command Type = commandType;

//attach the command parameters if they are provided

if (commandParamet ers != null)

{

AttachParameter s(command, commandParamete rs);

}

return;

}

//*************** *************** *************** *************** *********

//

// Execute a SqlCommand (that returns no resultset) against the database
specified in the connection string

// using the provided parameters.

//

// e.g.:

// int result = ExecuteNonQuery (connString, CommandType.Sto redProcedure,
"PublishOrders" , new SqlParameter("@ prodid", 24));

//

// param name="connectio nString" a valid connection string for a
SqlConnection

// param name="commandTy pe" the CommandType (stored procedure, text, etc.)

// param name="commandTe xt" the stored procedure name or T-SQL command

// param name="commandPa rameters" an array of SqlParamters used to execute
the command

// returns an int representing the number of rows affected by the command

//

//*************** *************** *************** *************** *********

public static int ExecuteNonQuery (string connectionStrin g, CommandType
commandType, string commandText, params SqlParameter[] commandParamete rs)

{

//create & open a SqlConnection, and dispose of it after we are done.

using (SqlConnection cn = new SqlConnection(c onnectionString ))

{

cn.Open();

//call the overload that takes a connection in place of the connection
string

return ExecuteNonQuery (cn, commandType, commandText, commandParamete rs);

}

}

//*************** *************** *************** *************** *********

//

// Execute a stored procedure via a SqlCommand (that returns no resultset)
against the database specified in

// the connection string using the provided parameter values. This method
will query the database to discover the parameters for the

// stored procedure (the first time each stored procedure is called), and
assign the values based on parameter order.

//

// This method provides no access to output parameters or the stored
procedure's return value parameter.

//

// e.g.:

// int result = ExecuteNonQuery (connString, "PublishOrders" , 24, 36);

//

// param name="connectio nString" a valid connection string for a
SqlConnection

// param name="spName" the name of the stored prcedure

// param name="parameter Values" an array of objects to be assigned as the
input values of the stored procedure

// returns an int representing the number of rows affected by the command

//

//*************** *************** *************** *************** *********

public static int ExecuteNonQuery (string connectionStrin g, string spName,
params object[] parameterValues )

{

//if we receive parameter values, we need to figure out where they go

if ((parameterValu es != null) && (parameterValue s.Length > 0))

{

//pull the parameters for this stored procedure from the parameter cache (or
discover them & populate the cache)

SqlParameter[] commandParamete rs =
SqlHelperParame terCache.GetSpP arameterSet(con nectionString, spName);

//assign the provided values to these parameters based on parameter order

AssignParameter Values(commandP arameters, parameterValues );

//call the overload that takes an array of SqlParameters

return ExecuteNonQuery (connectionStri ng, CommandType.Sto redProcedure,
spName, commandParamete rs);

}

//otherwise we can just call the SP without params

else

{

return ExecuteNonQuery (connectionStri ng, CommandType.Sto redProcedure,
spName);

}

}

//*************** *************** *************** *************** *********

//

// Execute a SqlCommand (that returns no resultset) against the specified
SqlConnection

// using the provided parameters.

//

// e.g.:

// int result = ExecuteNonQuery (conn, CommandType.Sto redProcedure,
"PublishOrders" , new SqlParameter("@ prodid", 24));

//

// param name="connectio n" a valid SqlConnection

// param name="commandTy pe" the CommandType (stored procedure, text, etc.)

// param name="commandTe xt" the stored procedure name or T-SQL command

// param name="commandPa rameters" an array of SqlParamters used to execute
the command

// returns an int representing the number of rows affected by the command

//

//*************** *************** *************** *************** *********

public static int ExecuteNonQuery (SqlConnection connection, CommandType
commandType, string commandText, params SqlParameter[] commandParamete rs)

{

//create a command and prepare it for execution

SqlCommand cmd = new SqlCommand();

PrepareCommand( cmd, connection, (SqlTransaction )null, commandType,
commandText, commandParamete rs);
//finally, execute the command.

int retval = cmd.ExecuteNonQ uery();
// detach the SqlParameters from the command object, so they can be used
again.

cmd.Parameters. Clear();

return retval;

}

//*************** *************** *************** *************** *********

//

// Execute a SqlCommand (that returns a resultset) against the database
specified in the connection string

// using the provided parameters.

//

// e.g.:

// DataSet ds = ExecuteDataset( connString, CommandType.Sto redProcedure,
"GetOrders" , new SqlParameter("@ prodid", 24));

//

// param name="connectio nString" a valid connection string for a
SqlConnection

// param name="commandTy pe" the CommandType (stored procedure, text, etc.)

// param name="commandTe xt" the stored procedure name or T-SQL command

// param name="commandPa rameters" an array of SqlParamters used to execute
the command

// returns a dataset containing the resultset generated by the command

//

//*************** *************** *************** *************** *********

public static DataSet ExecuteDataset( string connectionStrin g, CommandType
commandType, string commandText, params SqlParameter[] commandParamete rs)

{

//create & open a SqlConnection, and dispose of it after we are done.

using (SqlConnection cn = new SqlConnection(c onnectionString ))

{

cn.Open();

//call the overload that takes a connection in place of the connection
string

return ExecuteDataset( cn, commandType, commandText, commandParamete rs);

}

}

//*************** *************** *************** *************** *********

//

// Execute a stored procedure via a SqlCommand (that returns a resultset)
against the database specified in

// the connection string using the provided parameter values. This method
will query the database to discover the parameters for the

// stored procedure (the first time each stored procedure is called), and
assign the values based on parameter order.

//

// This method provides no access to output parameters or the stored
procedure's return value parameter.

//

// e.g.:

// DataSet ds = ExecuteDataset( connString, "GetOrders" , 24, 36);

//

// param name="connectio nString" a valid connection string for a
SqlConnection

// param name="spName" the name of the stored procedure

// param name="parameter Values" an array of objects to be assigned as the
input values of the stored procedure

// returns a dataset containing the resultset generated by the command

//

//*************** *************** *************** *************** *********

public static DataSet ExecuteDataset( string connectionStrin g, string spName,
params object[] parameterValues )

{

//if we receive parameter values, we need to figure out where they go

if ((parameterValu es != null) && (parameterValue s.Length > 0))

{

//pull the parameters for this stored procedure from the parameter cache (or
discover them & populate the cache)

SqlParameter[] commandParamete rs =
SqlHelperParame terCache.GetSpP arameterSet(con nectionString, spName);

//assign the provided values to these parameters based on parameter order

AssignParameter Values(commandP arameters, parameterValues );

//call the overload that takes an array of SqlParameters

return ExecuteDataset( connectionStrin g, CommandType.Sto redProcedure, spName,
commandParamete rs);

}

//otherwise we can just call the SP without params

else

{

return ExecuteDataset( connectionStrin g, CommandType.Sto redProcedure,
spName);

}

}
//*************** *************** *************** *************** *********

//

// Execute a SqlCommand (that returns a resultset) against the specified
SqlConnection

// using the provided parameters.

//

// e.g.:

// DataSet ds = ExecuteDataset( conn, CommandType.Sto redProcedure,
"GetOrders" , new SqlParameter("@ prodid", 24));

//

// param name="connectio n" a valid SqlConnection

// param name="commandTy pe" the CommandType (stored procedure, text, etc.)

// param name="commandTe xt" the stored procedure name or T-SQL command

// param name="commandPa rameters" an array of SqlParamters used to execute
the command

// returns a dataset containing the resultset generated by the command

//

//*************** *************** *************** *************** *********

public static DataSet ExecuteDataset( SqlConnection connection, CommandType
commandType, string commandText, params SqlParameter[] commandParamete rs)

{

//create a command and prepare it for execution

SqlCommand cmd = new SqlCommand();

PrepareCommand( cmd, connection, (SqlTransaction )null, commandType,
commandText, commandParamete rs);
//create the DataAdapter & DataSet

SqlDataAdapter da = new SqlDataAdapter( cmd);

DataSet ds = new DataSet();

//fill the DataSet using default values for DataTable names, etc.

da.Fill(ds);
// detach the SqlParameters from the command object, so they can be used
again.

cmd.Parameters. Clear();
//return the dataset

return ds;

}

//*************** *************** *************** *************** *********

//

// Execute a SqlCommand (that returns a 1x1 resultset) against the database
specified in the connection string

// using the provided parameters.

//

// e.g.:

// int orderCount = (int)ExecuteSca lar(connString,
CommandType.Sto redProcedure, "GetOrderCount" , new SqlParameter("@ prodid",
24));

//

// param name="connectio nString" a valid connection string for a
SqlConnection

// param name="commandTy pe" the CommandType (stored procedure, text, etc.)

// param name="commandTe xt" the stored procedure name or T-SQL command

// param name="commandPa rameters" an array of SqlParamters used to execute
the command

// returns an object containing the value in the 1x1 resultset generated by
the command

//

//*************** *************** *************** *************** *********

public static object ExecuteScalar(s tring connectionStrin g, CommandType
commandType, string commandText, params SqlParameter[] commandParamete rs)

{

//create & open a SqlConnection, and dispose of it after we are done.

using (SqlConnection cn = new SqlConnection(c onnectionString ))

{

cn.Open();

//call the overload that takes a connection in place of the connection
string

return ExecuteScalar(c n, commandType, commandText, commandParamete rs);

}

}

//*************** *************** *************** *************** *********

//

// Execute a stored procedure via a SqlCommand (that returns a 1x1
resultset) against the database specified in

// the connection string using the provided parameter values. This method
will query the database to discover the parameters for the

// stored procedure (the first time each stored procedure is called), and
assign the values based on parameter order.

//

// This method provides no access to output parameters or the stored
procedure's return value parameter.

//

// e.g.:

// int orderCount = (int)ExecuteSca lar(connString, "GetOrderCount" , 24, 36);

//

// param name="connectio nString" a valid connection string for a
SqlConnection

// param name="spName" the name of the stored procedure

// param name="parameter Values" an array of objects to be assigned as the
input values of the stored procedure

// returns an object containing the value in the 1x1 resultset generated by
the command

//

//*************** *************** *************** *************** *********

public static object ExecuteScalar(s tring connectionStrin g, string spName,
params object[] parameterValues )

{

//if we receive parameter values, we need to figure out where they go

if ((parameterValu es != null) && (parameterValue s.Length > 0))

{

//pull the parameters for this stored procedure from the parameter cache (or
discover them & populate the cache)

SqlParameter[] commandParamete rs =
SqlHelperParame terCache.GetSpP arameterSet(con nectionString, spName);

//assign the provided values to these parameters based on parameter order

AssignParameter Values(commandP arameters, parameterValues );

//call the overload that takes an array of SqlParameters

return ExecuteScalar(c onnectionString , CommandType.Sto redProcedure, spName,
commandParamete rs);

}

//otherwise we can just call the SP without params

else

{

return ExecuteScalar(c onnectionString , CommandType.Sto redProcedure, spName);

}

}

//*************** *************** *************** *************** *********

//

// Execute a SqlCommand (that returns a 1x1 resultset) against the specified
SqlConnection

// using the provided parameters.

//

// e.g.:

// int orderCount = (int)ExecuteSca lar(conn, CommandType.Sto redProcedure,
"GetOrderCount" , new SqlParameter("@ prodid", 24));

//

// param name="connectio n" a valid SqlConnection

// param name="commandTy pe" the CommandType (stored procedure, text, etc.)

// param name="commandTe xt" the stored procedure name or T-SQL command

// param name="commandPa rameters" an array of SqlParamters used to execute
the command

// returns an object containing the value in the 1x1 resultset generated by
the command

//

//*************** *************** *************** *************** *********

public static object ExecuteScalar(S qlConnection connection, CommandType
commandType, string commandText, params SqlParameter[] commandParamete rs)

{

//create a command and prepare it for execution

SqlCommand cmd = new SqlCommand();

PrepareCommand( cmd, connection, (SqlTransaction )null, commandType,
commandText, commandParamete rs);
//execute the command & return the results

object retval = cmd.ExecuteScal ar();
// detach the SqlParameters from the command object, so they can be used
again.

cmd.Parameters. Clear();

return retval;
}

}

//*************** *************** *************** *************** *********

//

// SqlHelperParame terCache provides functions to leverage a static cache of
procedure parameters, and the

// ability to discover parameters for stored procedures at run-time.

//

//*************** *************** *************** *************** *********

public sealed class SqlHelperParame terCache

{

//*************** *************** *************** *************** *********

//

// Since this class provides only static methods, make the default
constructor private to prevent

// instances from being created with "new SqlHelperParame terCache()".

//

//*************** *************** *************** *************** *********

private SqlHelperParame terCache() {}

private static Hashtable paramCache = Hashtable.Synch ronized(new
Hashtable());

//*************** *************** *************** *************** *********

//

// resolve at run time the appropriate set of SqlParameters for a stored
procedure

//

// param name="connectio nString" a valid connection string for a
SqlConnection

// param name="spName" the name of the stored procedure

// param name="includeRe turnValueParame ter" whether or not to include their
return value parameter

//

//*************** *************** *************** *************** *********

private static SqlParameter[] DiscoverSpParam eterSet(string
connectionStrin g, string spName, bool includeReturnVa lueParameter)

{

using (SqlConnection cn = new SqlConnection(c onnectionString ))

using (SqlCommand cmd = new SqlCommand(spNa me,cn))

{

cn.Open();

cmd.CommandType = CommandType.Sto redProcedure;

SqlCommandBuild er.DeriveParame ters(cmd);

if (!includeReturn ValueParameter)

{

cmd.Parameters. RemoveAt(0);

}

SqlParameter[] discoveredParam eters = new
SqlParameter[cmd.Parameters. Count];;

cmd.Parameters. CopyTo(discover edParameters, 0);

return discoveredParam eters;

}

}

private static SqlParameter[] CloneParameters (SqlParameter[]
originalParamet ers)

{

//deep copy of cached SqlParameter array

SqlParameter[] clonedParameter s = new
SqlParameter[originalParamet ers.Length];

for (int i = 0, j = originalParamet ers.Length; i < j; i++)

{

clonedParameter s[i] =
(SqlParameter)( (ICloneable)ori ginalParameters[i]).Clone();

}

return clonedParameter s;

}

//*************** *************** *************** *************** *********

//

// add parameter array to the cache

//

// param name="connectio nString" a valid connection string for a
SqlConnection

// param name="commandTe xt" the stored procedure name or T-SQL command

// param name="commandPa rameters" an array of SqlParamters to be cached

//

//*************** *************** *************** *************** *********

public static void CacheParameterS et(string connectionStrin g, string
commandText, params SqlParameter[] commandParamete rs)

{

string hashKey = connectionStrin g + ":" + commandText;

paramCache[hashKey] = commandParamete rs;

}

//*************** *************** *************** *************** *********

//

// Retrieve a parameter array from the cache

//

// param name="connectio nString" a valid connection string for a
SqlConnection

// param name="commandTe xt" the stored procedure name or T-SQL command

// returns an array of SqlParamters

//

//*************** *************** *************** *************** *********

public static SqlParameter[] GetCachedParame terSet(string connectionStrin g,
string commandText)

{

string hashKey = connectionStrin g + ":" + commandText;

SqlParameter[] cachedParameter s = (SqlParameter[])paramCache[hashKey];
if (cachedParamete rs == null)

{

return null;

}

else

{

return CloneParameters (cachedParamete rs);

}

}

//*************** *************** *************** *************** *********

//

// Retrieves the set of SqlParameters appropriate for the stored procedure

//

// This method will query the database for this information, and then store
it in a cache for future requests.

//

// param name="connectio nString" a valid connection string for a
SqlConnection

// param name="spName" the name of the stored procedure

// returns an array of SqlParameters

//

//*************** *************** *************** *************** *********

public static SqlParameter[] GetSpParameterS et(string connectionStrin g,
string spName)

{

return GetSpParameterS et(connectionSt ring, spName, false);

}

//*************** *************** *************** *************** *********

//

// Retrieves the set of SqlParameters appropriate for the stored procedure

//

// This method will query the database for this information, and then store
it in a cache for future requests.

//

// param name="connectio nString" a valid connection string for a
SqlConnection

// param name="spName" the name of the stored procedure

// param name="includeRe turnValueParame ter" a bool value indicating whether
the return value parameter should be included in the results

// returns an array of SqlParameters

//

//*************** *************** *************** *************** *********

public static SqlParameter[] GetSpParameterS et(string connectionStrin g,
string spName, bool includeReturnVa lueParameter)

{

string hashKey = connectionStrin g + ":" + spName +
(includeReturnV alueParameter ? ":include ReturnValue Parameter":"");

SqlParameter[] cachedParameter s;
cachedParameter s = (SqlParameter[])paramCache[hashKey];

if (cachedParamete rs == null)

{

cachedParameter s = (SqlParameter[])(paramCache[hashKey] =
DiscoverSpParam eterSet(connect ionString, spName,
includeReturnVa lueParameter));

}
return CloneParameters (cachedParamete rs);

}

}

}

"Richard Blewett [DevelopMentor]" <ri******@devel op.com> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
using(SqlConnec tion conn = new SqlConnection(< connection string>))
{
SqlCommand cmd = new SqlCommand("MyS PName", conn);
cmd.CommandType = CommandType.Sto redProcedure;
cmd.Paramaters. Add(new SqlParameter(.. .));
conn.Open();
cmd.ExecuteNonQ uery(); // for an SP that doesn't return a result set or scalar value (e.g. count(*)) cmd.ExecuteScal ar(); // for an SP that returns a scalar value
using(SqlDataRe ader r = cmd.ExecuteRead er())// for an SP that returns a result set {
// process results
}
XmlReader r = cmd.ExecuteXmlR eader(); // for an SP that returns XML
// process XML
}

Regards

Richard Blewett - DevelopMentor
http://staff.develop.com/richardb/weblog

nntp://news.microsoft. com/microsoft.publi c.dotnet.langua ges.csharp/<ez************ *@tk2msftngp13. phx.gbl>
How can I run stored procedure (MSSQL) ?

---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.771 / Virus Database: 518 - Release Date: 28/09/2004

[microsoft.publi c.dotnet.langua ges.csharp]

Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
22134
by: dinesh prasad | last post by:
I'm trying to use a servlet to process a form, then send that data to an SQL server stored procedure. I'm using the WebLogic 8 App. server. I am able to retrieve database information, so I know my application server can talk to the database. I've determined the failure occurs when the the following statement is executed: cstmt.execute(); (due to the failure of println statements placed afterwards). I get the following error after trying to...
0
6698
by: Nashat Wanly | last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and Visual C# .NET View products that this article applies to. This article was previously published under Q310070 For a Microsoft Visual Basic .NET version of this article, see 308049. For a Microsoft Visual C++ .NET version of this article, see 310071. For a Microsoft Visual J# .NET version of this article, see 320627. This article refers to the following Microsoft .NET...
3
2802
by: Rhino | last post by:
I've spent the last couple of hours trying to figure out how to debug a Java stored procedure and am just going in circles. The last straw came when I got "Cannot open input stream for default" when I launched the IBM Distributed Debugger via D:\IBMDebug>idebug.exe -qdaemon -quiport=8000,8001 First, a bit of background. I am running DB2 V7.2 with Fixpack 9 applied on Windows XP Professional (all critical service applied). I've written...
4
3187
by: Rhino | last post by:
Is it possible for a Java Stored Procedure in DB2 V7.2 (Windows) to pass a Throwable back to the calling program as an OUT parameter? If yes, what datatype should I use when registering the Throwable as an OUT parameter and what datatype should I use in the CREATE PROCEDURE and DROP PROCEDURE statements? Here's what I tried: - the method signature for the stored procedure included: Throwable throwable
8
7940
by: Thomasb | last post by:
With a background in MS SQL Server programming I'm used to temporary tables. Have just started to work with DB2 ver 7 on z/OS and stumbled into the concept of GLOBAL TEMPORARY TABLE. I have created a temporary database with a tables space. Verified that DECLARE GLOBAL TEMPORARY TABLE TEMP (A INTEGER); INSERT INTO SESSION.TEMP VALUES(10); SELECT A FROM SESSION.TEMP; works from a query tool.
0
2644
by: Amber | last post by:
Stored procedures are faster and more efficient than in-line SQL statements. In this article we will look at two SQL Server stored procedures; one using an input parameter and one not, and see how to call them from an ASP.Net page Every modern database system has a stored procedure language. SQL Server is no different and has a relatively sophisticated and easy to use system. This article will not attempt to go into depth in explaining...
3
3475
by: kd | last post by:
Hi All, How to debug a stored procedure? Thanks, kd
7
3457
by: Dabbler | last post by:
I'm using an ObjectDataSource with a stored procedure and am getting the following error when trying to update (ExecuteNonQuery): System.Data.SqlClient.SqlException: Procedure or Function 'UpdateRegistrant' expects parameter '@EMail', which was not supplied. The field value was null in the database and not changed in the FormView so is null going back into the stored procedure. I'm stumped and would greatly appreciate any suggestions.
2
4101
by: jed | last post by:
I have created this example in sqlexpress ALTER PROCEDURE . @annualtax FLOAT AS BEGIN SELECT begin1,end1,deductedamount,pecentageextra FROM tax
0
8689
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9178
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9035
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8916
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6534
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4376
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4631
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3058
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2010
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.