无法隐式转换类型'字符串'到c#中的System.Data.DataSet

时间:2014-03-17 04:51:12

标签: c# asp.net

当我获得DropdownList的选定值并分配给DataSet时,我收到以下错误:"无法隐式转换类型' string'到' System.Data.DataSet'" Bellow是我用来填充DropdownList的方法:

DrdReqCode.DataSource = dt;
DrdReqCode.DataTextField = dt.Columns[0].ColumnName;
DrdReqCode.DataBind();
DrdReqCode.Items.Insert(0, new ListItem("", "0"));

获取DropdownList的选定值:

 string reqcode = DrdReqCode.SelectedItem.Value;
 SQLDataProvider SqlProvider = new SQLDataProvider();
 DataSet ds = SqlProvider.GenerateTestCaseCode(reqcode);

GenerateTestCaseCode方法:

public String GenerateTestCaseCode(string Reqcode)
{       
     try
     {

        string TestCaseCode = "";

        string strsql = "select ISNULL(Max(TestCaseID),0)+1 from TestCaseMaster TM inner join RequirementMaster RM on TM.RequirementID=RM.RequirementID"
                               + " where RequestCode='" + Reqcode+ "'";

        DataSet ds = dataAccess.GetQueryData(strsql);

                DataTable dt = ds.Tables[0];

                int MaxTestCaseCode;
                // RequestCode = projname.Substring(0, 3);

                if (dt.Rows.Count > 0)
                {
                    MaxTestCaseCode = Convert.ToInt32(dt.Rows[0][0]);

                    TestCaseCode =Reqcode+ " -T-" + MaxTestCaseCode.ToString("000");

                }
                return TestCaseCode;
            }

            catch (Exception ex)
            {

                throw;

            }

 }

0 个答案:

没有答案