-2
A
回答
1
using (SqlConnection conn = new SqlConnection(your-connection-string)) {
conn.Open();
// 1. create a command object identifying the stored procedure
SqlCommand cmd = new SqlCommand("your-procedure-name", conn);
// 2. set the command object so it knows to execute a stored procedure
cmd.CommandType = CommandType.StoredProcedure;
// 3. add parameter to command, which will be passed to the stored procedure
cmd.Parameters.Add(new SqlParameter("@Username", textBox1.Text));
cmd.Parameters.Add(new SqlParameter("@Password", textBox2.Text));
// execute the command
using (SqlDataReader result = cmd.ExecuteReader()) {
// iterate through results, printing each to console
while (result .Read())
{
// Name and Password Should Match with your proc col name
var userName = result["Name"].toString();
var password = result["password"].toString();
}
}
}
更多詳情,請閱讀本該
相關問題
- 1. 編輯存儲過程和更新表格適配器
- 2. 創建表格適配器時,不會顯示存儲過程
- 3. 存儲過程中的「執行」不適用於「OPENROWSET」
- 4. 不能在軌控制檯(ActiveRecord的 - SQLSERVER適配器)執行存儲過程
- 5. 如何使用表中的值執行存儲過程
- 6. 使用存儲過程執行SSIS pacakge
- 7. 使用JOOQ執行Firebird存儲過程
- 8. 使用ODB ORM執行存儲過程
- 9. 使用Hibernate執行Oracle存儲過程
- 10. 使用DBVisualizer執行MYSQL存儲過程
- 11. 執行存儲過程使用ADO.NET
- 12. 使用OPENQUERY執行存儲過程
- 13. 執行存儲過程的表
- 14. 在c#中使用linq執行存儲過程#
- 15. 如何使用c#通過odbc執行存儲過程?
- 16. 在操作管理器配置中執行Oracle存儲過程
- 17. C#執行存儲過程與context.Connection
- 18. C# - 批處理執行存儲過程
- 19. C#&SQL Server:執行存儲過程
- 20. 使用C#中的存儲過程檢索多個表格
- 21. 在存儲過程中執行帶參數的存儲過程
- 22. 如何使用遊標從表中執行存儲過程?
- 23. 對多個表執行存儲過程
- 24. 是否可以從適配器執行存儲庫調用
- 25. 執行存儲過程OnClick
- 26. 執行存儲過程
- 27. 執行SQL存儲過程
- 28. 執行存儲過程
- 29. Rails執行存儲過程
- 30. 當執行存儲過程
顯示我們的實際VB代碼,不粘貼到一個C#類的VB代碼。 – mjwills
而不是張貼執行代碼發佈代碼的屏幕截圖。 –
這是C#中的代碼,我使用的數據綁定已經解決了 –