|
|
@ -5,9 +5,10 @@ using System; |
|
|
|
using System.Data; |
|
|
|
using System.Data; |
|
|
|
using System.Globalization; |
|
|
|
using System.Globalization; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using ICSharpCode.Reports.Core.Factories; |
|
|
|
using ICSharpCode.Reports.Core.Project.Interfaces; |
|
|
|
using ICSharpCode.Reports.Core.Project.Interfaces; |
|
|
|
|
|
|
|
|
|
|
|
namespace ICSharpCode.Reports.Core |
|
|
|
namespace ICSharpCode.Reports.Core.DataAccess |
|
|
|
{ |
|
|
|
{ |
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Description of DataAccess.
|
|
|
|
/// Description of DataAccess.
|
|
|
@ -26,7 +27,7 @@ namespace ICSharpCode.Reports.Core |
|
|
|
} |
|
|
|
} |
|
|
|
this.reportSettings = reportSettings; |
|
|
|
this.reportSettings = reportSettings; |
|
|
|
if (connectionObject == null) { |
|
|
|
if (connectionObject == null) { |
|
|
|
this.connectionObject = ConnectionObjectFactory.BuildConnectionObject(reportSettings.ConnectionString); |
|
|
|
this.connectionObject = ConnectionObjectFactory.BuildConnectionObject(reportSettings); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
this.connectionObject = connectionObject; |
|
|
|
this.connectionObject = connectionObject; |
|
|
|
} |
|
|
|
} |
|
|
@ -40,7 +41,6 @@ namespace ICSharpCode.Reports.Core |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void CheckConnection() |
|
|
|
private void CheckConnection() |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (this.connectionObject.Connection.State == ConnectionState.Open) { |
|
|
|
if (this.connectionObject.Connection.State == ConnectionState.Open) { |
|
|
@ -50,7 +50,6 @@ namespace ICSharpCode.Reports.Core |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public DataSet ReadData() |
|
|
|
public DataSet ReadData() |
|
|
|
{ |
|
|
|
{ |
|
|
|
try { |
|
|
|
try { |
|
|
@ -70,8 +69,7 @@ namespace ICSharpCode.Reports.Core |
|
|
|
// We have to check if there are parameters for this Query, if so
|
|
|
|
// We have to check if there are parameters for this Query, if so
|
|
|
|
// add them to the command
|
|
|
|
// add them to the command
|
|
|
|
|
|
|
|
|
|
|
|
BuildQueryParameters(command,reportSettings.ParameterCollection); |
|
|
|
BuildQueryParameters(command,reportSettings.SqlParameters); |
|
|
|
|
|
|
|
|
|
|
|
IDbDataAdapter adapter = connectionObject.CreateDataAdapter(command); |
|
|
|
IDbDataAdapter adapter = connectionObject.CreateDataAdapter(command); |
|
|
|
DataSet ds = new DataSet(); |
|
|
|
DataSet ds = new DataSet(); |
|
|
|
ds.Locale = CultureInfo.CurrentCulture; |
|
|
|
ds.Locale = CultureInfo.CurrentCulture; |
|
|
@ -87,17 +85,17 @@ namespace ICSharpCode.Reports.Core |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void BuildQueryParameters (IDbCommand cmd, |
|
|
|
private static void BuildQueryParameters (IDbCommand cmd, |
|
|
|
ParameterCollection parameterCollection) |
|
|
|
SqlParameterCollection parameterCollection) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (parameterCollection != null && parameterCollection.Count > 0) { |
|
|
|
if (parameterCollection != null && parameterCollection.Count > 0) { |
|
|
|
|
|
|
|
|
|
|
|
IDbDataParameter cmdPar = null; |
|
|
|
IDbDataParameter cmdPar = null; |
|
|
|
System.Collections.Generic.List<SqlParameter> sq = parameterCollection.ExtractSqlParameters(); |
|
|
|
|
|
|
|
|
|
|
|
foreach (SqlParameter par in parameterCollection) { |
|
|
|
foreach (SqlParameter par in sq) { |
|
|
|
|
|
|
|
cmdPar = cmd.CreateParameter(); |
|
|
|
cmdPar = cmd.CreateParameter(); |
|
|
|
cmdPar.ParameterName = par.ParameterName; |
|
|
|
cmdPar.ParameterName = par.ParameterName; |
|
|
|
|
|
|
|
Console.WriteLine(""); |
|
|
|
|
|
|
|
Console.WriteLine("BuildQueryParameters {0} - {1}",par.ParameterName,par.ParameterValue); |
|
|
|
if (par.DataType != System.Data.DbType.Binary) { |
|
|
|
if (par.DataType != System.Data.DbType.Binary) { |
|
|
|
cmdPar.DbType = par.DataType; |
|
|
|
cmdPar.DbType = par.DataType; |
|
|
|
cmdPar.Value = par.ParameterValue; |
|
|
|
cmdPar.Value = par.ParameterValue; |