2012-05-29 135 views

回答

7
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); 
    } 
} 
+0

我會試試:)感謝您的快速答覆!〜 – user1192047

+0

@MassimilianoPeluso我覺得這部分'command.Paremeters.Add( 「@ yourParameter」,OdbcType.NChar,50).value的= yourParameter'需求分成兩行,一個添加參數,另一個設置值。 –

+0

aF是正確的,我需要改變,但其餘的工作!感謝馬西 – user1192047