Csharp/C Sharp by API/System.Data/CommandType

Материал из .Net Framework эксперт
Перейти к: навигация, поиск

CommandType.StoredProcedure

 
using System;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.Data;
class Class1 {
   static void Main(string[] args) {
    SqlConnection cnnUserMan;
    SqlCommand cmmUser;
    object objNumUsers;
    // Instantiate and open the connection
    cnnUserMan = new SqlConnection("server=(local)\\SQLEXPRESS;database=MyDatabase;Integrated Security=SSPI");
    cnnUserMan.Open();
    // Instantiate and initialize command
    cmmUser = new SqlCommand("SimpleStoredProcedure", cnnUserMan);
    cmmUser.rumandType = CommandType.StoredProcedure;
    objNumUsers = cmmUser.ExecuteScalar();
    Console.WriteLine(objNumUsers.ToString());
   }
}