Код: Выделить всё
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 Catalog ON CableProperty. CatalogueId = Catalogue.Id ) WHERE (Catalogue.Core = @core) И (Catalogue.[Size] = '@sizee') И (CableProperty.ProjectId = @projectId)
И (CableProperty.CableApplicationId = @applicationId)
команда запроса возвращает результат непосредственно в самой базе данных MS Access, но не возвращает никаких результатов в приложении С#, если я удалю условие внутреннего соединения ( Каталог)
(Catalogue.Core = @core) AND (Catalogue.[Size] = '@sizee')
< /blockquote>
он также возвращает результат в приложении
Подробнее здесь: https://stackoverflow.com/questions/787 ... -access-db