#2 19.02.08 12:59
Re: помогите с [C++] и [MS SQL SERVER 2005]
http://msdn2.microsoft.com/en-us/library/ms254937.aspx
пример оттуда на c#, но так как пространство имен одно, легко правится под ++
Код: csharp:
static void GetSalesByCategory(string connectionString, string categoryName) { using (SqlConnection connection = new SqlConnection(connectionString)) { // Create the command and set its properties. SqlCommand command = new SqlCommand(); command.Connection = connection; command.CommandText = "SalesByCategory"; command.CommandType = CommandType.StoredProcedure; // Add the input parameter and set its properties. SqlParameter parameter = new SqlParameter(); parameter.ParameterName = "@CategoryName"; parameter.SqlDbType = SqlDbType.NVarChar; parameter.Direction = ParameterDirection.Input; parameter.Value = categoryName; // Add the parameter to the Parameters collection. command.Parameters.Add(parameter); // Open the connection and execute the reader. connection.Open(); SqlDataReader reader = command.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { Console.WriteLine("{0}: {1:C}", reader[0], reader[1]); } } else { Console.WriteLine("No rows found."); } reader.Close(); } }
Исправлено rzk (19.02.08 13:02)
Offline

