本文介绍了如何通过将参数传递给存储过程并将其存储在DataSet中来从表中检索数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 下面是我的代码,我无法检索数据并将其存储在Dataset ds中,我是初学者所以不知道如何解决这个问题。 public static DataSet GetTestDetails(string testVariable) { SqlConnection sqlConn = new SqlConnection(); sqlConn.ConnectionString = ConfigurationManager.AppSettings [connTestConn]; SqlParameter parameter1 = null; 尝试 { parameter1 = new SqlParameter(@ TestVariable,SqlDbType.VarChar); parameter1.Value = testVariable; DataSet ds = SqlHelper.ExecuteDataSet(sqlConn,TestStoredProcedure,parameter1); 返回ds; } 终于 { parameter1 = null; if(sqlConn!= null && sqlConn.State == ConnectionState.Open) { sqlConn.Close(); } } } 感谢提前:)Below is my code,I am not able to retrieve the data and store it in the Dataset ds, I am a beginner so don't know how to solve this.public static DataSet GetTestDetails(string testVariable) { SqlConnection sqlConn = new SqlConnection(); sqlConn.ConnectionString = ConfigurationManager.AppSettings["connTestConn"]; SqlParameter parameter1 = null; try { parameter1 = new SqlParameter("@TestVariable", SqlDbType.VarChar); parameter1.Value = testVariable; DataSet ds = SqlHelper.ExecuteDataSet(sqlConn, "TestStoredProcedure", parameter1); return ds; } finally { parameter1 = null; if (sqlConn != null && sqlConn.State == ConnectionState.Open) { sqlConn.Close(); } } }thanks in Advance :)推荐答案 尝试 C# Dataset Tutorial [ ^ ] http:// www.dotnetperls.com/dataset [ ^ ] http://www.homeandlearn.co.uk/csharp/csharp_s12p6.html [ ^ ] TryC# Dataset Tutorial [^]http://www.dotnetperls.com/dataset[^]http://www.homeandlearn.co.uk/csharp/csharp_s12p6.html[^] 这篇关于如何通过将参数传递给存储过程并将其存储在DataSet中来从表中检索数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-25 09:37