如何使用c#通过odbc执行存储过程?
我想在没有 sql 注入风险的情况下执行它,我该怎么做?
using (OdbcConnection connection = new OdbcConnection(connectionString))
using (OdbcCommand command = connection.CreateCommand())
{
command.CommandText = commandText //your store procedure name;
command.CommandType = CommandType.StoredProcedure;
command.Paremeters.Add("@yourParameter", OdbcType.NChar, 50).Value = yourParameter
DataTable dataTable = new DataTable();
connection.Open();
using (OdbcDataAdapter adapter = new OdbcDataAdapter(command))
{
adapter.Fill(dataTable);
}
}