Я сделал это:
Код: Выделить всё
var parameters = new KeyValuePair[]
{
new KeyValuePair("@ProjectId", currentInfo.ProjectId),
new KeyValuePair("@core", Convert.ToInt16(catalogue.Core.ToString())),
new KeyValuePair("@sizee", catalogue.Size)),
new KeyValuePair("@applicationId", Convert.ToInt32(applicationComboBox.SelectedValue.ToString()))
};
DataTable typesTable = helper.GetRowsByQuery("FillType",parameters, currentInfo.DBPath);
Код: Выделить всё
public DataTable GetRowsByQuery(string queryOrTable, KeyValuePair[] parameters, string dbPath)
{
DataTable table = new DataTable();
OleDbDataAdapter adapter = new OleDbDataAdapter();
OleDbConnection connection = new OleDbConnection(GetStringConnection(dbPath));
string sqlCommand = GetSqlCommand(queryOrTable);
OleDbCommand command = new OleDbCommand(sqlCommand, connection);
if (parameters != null)
{
foreach (KeyValuePair o in parameters)
{
var parameter = new OleDbParameter(o.Key, o.Value);
SetOleDbTypeAndSize(parameter, o.Value);
command.Parameters.Add(parameter);
}
}
command.CommandText = sqlCommand;
adapter.SelectCommand = command;
try
{
connection.Open();
if (table == null)
{
table = new DataTable();
table.Locale = System.Globalization.CultureInfo.InvariantCulture;
adapter.FillSchema(table, SchemaType.Source);
}
adapter.Fill(table);
}
finally
{
if (connection.State == ConnectionState.Open)
{
connection.Close();
}
}
return table;
}
Код: Выделить всё
SELECT DISTINCT Catalogue.Type
FROM (CableProperty
INNER JOIN Catalogue ON CableProperty.CatalogueId = Catalogue.Id)
WHERE (Catalogue.Core = @core)
AND (Catalogue.[Size] = '@sizee')
AND (CableProperty.ProjectId = @projectId)
AND (CableProperty.CableApplicationId = @applicationId)
Если Я удаляю условие внутреннего соединения в Каталоге:
Код: Выделить всё
(Catalogue.Core = @core) AND (Catalogue.[Size] = '@sizee')
Подробнее здесь: https://stackoverflow.com/questions/787 ... ss-databas