SqlCommand object and stored procedures in SQL Server 2000 
Author Message
 SqlCommand object and stored procedures in SQL Server 2000

Hi

I have some questions about SqlCommand object and stored procedures in SQL
Server 2000.
1) What is it the Prepare() statement do? In the documentation they do a
ExecuteNonQuery after the Prepare, but that always fail for me and I can not
see anything in the SQL Profiler .
2) The Parameters[x].IsNullable == false, but I can still use DBNull.Value.
Why?
3) When I don't set a parameter, the SqlCommand object uses the default. For

output, is sent to the server when my SP is executed, see below. If you have
a SP with several parameters but you only uses some of them, then a lot of
unnessary network trafic is generated by the SqlCommand object. How do I do
if only want to send thoose parameters is use?

Thanks in advance
/Niklas

--The stored procedure
CREATE PROCEDURE mySp




AS


 return 1
GO

//The C# console code
using System;
using System.Data.SqlClient;

namespace ConsoleApplication6
{
 class Class1
 {
  [STAThread]
  static void Main(string[] args)
  {
   SqlConnection myConnection = new SqlConnection("user
id=Developer;password=;initial catalog=test;data source=LocalHost;Connect
Timeout=30");
   myConnection.Open();
   SqlCommand myCommand = new SqlCommand("mySp", myConnection);
   myCommand.CommandType = System.Data.CommandType.StoredProcedure;
   //Why does my output become a InputOutput? How do I do do get a Output?
   SqlCommandBuilder.DeriveParameters(myCommand);
   //What is it axactly the Prepare do?
   myCommand.Prepare();


  //Why can I use NULL?


   myCommand.ExecuteNonQuery();


  }
 }

Quote:
}



Fri, 22 Oct 2004 22:19:05 GMT  
 SqlCommand object and stored procedures in SQL Server 2000
Note, this is the C# newsgroup,
  you can do:  if, then, else, do, for, while, switch, case, class, struct...

only use the specific:
   microsoft.public.dotnet.framework.adonet

--
  NETMaster  (Thomas Scheidegger)
  http://www.cetus-links.org/oo_csharp.html

Quote:

> I have some questions about SqlCommand object and stored procedures in SQL
> Server 2000.
> 1) What is it the Prepare() statement do? In the documentation they do a
> ExecuteNonQuery after the Prepare, but that always fail for me and I can not
> see anything in the SQL Profiler .
> 2) The Parameters[x].IsNullable == false, but I can still use DBNull.Value.
> Why?
> 3) When I don't set a parameter, the SqlCommand object uses the default. For

> output, is sent to the server when my SP is executed, see below. If you have
> a SP with several parameters but you only uses some of them, then a lot of
> unnessary network trafic is generated by the SqlCommand object. How do I do
> if only want to send thoose parameters is use?
> --The stored procedure
> CREATE PROCEDURE mySp




> AS


>  return 1
> GO



Sat, 23 Oct 2004 16:39:47 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Executing stored procedure on sql server 2000 using c program

2. Porting SQL Server 7 Stored Procedures to Access 2000

3. Extended Stored Procedures in SQL Server

4. Invoking Stored Procedures of SQL Server from VC ++

5. Debugging extended stored procedures in SQL Server

6. Variable names for tables in MS SQL Server stored procedures

7. Debugging a Sql Server Stored Procedure.

8. Debugging extended stored procedures in SQL Server

9. Debugging Extended Stored Procedures on SQL Server 6.5

10. How to pass parameter to a Stored Procedure of SQL Server

11. Returning Tables from SqlServer Stored Procedures to a SqlCommand

12. SQL 7 OLE Automation Object via Stored Procedure

 

 
Powered by phpBB® Forum Software