[英]How to execute a stored procedure via odbc using c#?
如何使用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);
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.