2009-07-13 21 views

回答

5

ADO.Net獲得大小具有此功能。你要使用

SqlCommandBuilder.DeriveParameters(mySqlCommand)

這將填充你的SqlCommand對象「的MySqlCommand」,名稱和參數的類型。但是,它確實需要額外的數據庫調用。

如果谷歌圍繞他們有在網絡上的幾個演練。 4Guys有一個here

+0

非常感謝,該4guys鏈接佔地面積什麼我試着去才達到,動態報告工具,基於存儲過程 – 2009-07-13 20:56:28

1

沒有,但你可以從information_schema.parameters

例子程序得到它

create procedure prtest 
@id int, 
@name varchar(200), 
@value decimal(20,10) 
as 
select 'bla' 

go 

現在運行此查詢

select parameter_name,data_type,* from information_schema.parameters 
where specific_name = 'prtest' 
order by ordinal_position 

輸出

@id int 
@name varchar 
@value decimal 

你ST生病需要從CHARACTER_MAXIMUM_LENGTH,NUMERIC_PRECISION,NUMERIC_SCALE

0

是的,你可以通過使用SqlCommandBuilder類的DeriveParameters方法...

using (var conn = new SqlConnection(myConnectionString)) 
using (var cmd = new SqlCommand("dbo.MyStoredProc", conn)) 
{ 
    conn.Open(); 
    cmd.CommandType = System.Data.CommandType.StoredProcedure; 
    SqlCommandBuilder.DeriveParameters(cmd); 

    foreach (SqlParameter item in cmd.Parameters) 
    { 
     Console.WriteLine(item.ParameterName); 
    } 
} 
相關問題