Do you have your application configuration setup correctly?
Here is a quick example on calling a stored procedure via Enterprise Library Data Access Block:
using System;
using System.Data;
using Microsoft.Practices.EnterpriseLibrary.Data;
namespace MyTest
{
internal class Program
{
private static void Main(string[] args)
{
var database = DatabaseFactory.CreateDatabase();
var command = database.GetStoredProcCommand("SomeSP");
using (IDataReader reader = database.ExecuteReader(command))
{
while (reader.Read())
{
Console.WriteLine("X: {0} Y: {1} Z: {2}",
reader["SomeField"],
reader["AnothterField"],
reader["Enabled"]);
}
}
Console.ReadLine();
}
}
}
And the corresponding app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</configSections>
<connectionStrings>
<add
name="DB"
providerName="System.Data.SqlClient"
connectionString="server=(local)\SQLEXPRESS;database=YourDB;Integrated Security=true" />
</connectionStrings>
<dataConfiguration defaultDatabase="DB"/>
</configuration>
I ran into that issue when I didn't have the defaultDatabase set to a corresponding connection string.