如何将其转换为参数



我对参数没有任何想法,我正在制作日期时间记录,我的数据库仅在Access 2010 Microsoft。如何将代码切换到参数?

[!在此处输入图像描述][1]][1]

            string EmployeeTimeEnrtyMapping;
        StringBuilder sb = new StringBuilder();

        sb.Append("INSERT INTO TimeEntryTimeSheet (");
        sb.Append("CutoffId,");
        sb.Append("EmployeeId,");
        sb.Append("Dayhrs1,");
        sb.Append("Dayhrs2,");
        sb.Append("Dayhrs3,");
        sb.Append("Dayhrs4,");
        sb.Append("Dayhrs5,");
        sb.Append("Dayhrs6,");
        sb.Append("Dayhrs7,");
        sb.Append("Dayhrs8,");
        sb.Append("Dayhrs9,");
        sb.Append("Dayhrs10,");
        sb.Append("Dayhrs11,");
        sb.Append("Dayhrs12,");
        sb.Append("Dayhrs13,");
        sb.Append("Dayhrs14,");
        sb.Append("Dayhrs15,");
        sb.Append("DayhrsOT1,");
        sb.Append("DayhrsOT2,");
        sb.Append("DayhrsOT3,");
        sb.Append("DayhrsOT4,");
        sb.Append("DayhrsOT5,");
        sb.Append("DayhrsOT6,");
        sb.Append("DayhrsOT7,");
        sb.Append("DayhrsOT8,");
        sb.Append("DayhrsOT9,");
        sb.Append("DayhrsOT10,");
        sb.Append("DayhrsOT11,");
        sb.Append("DayhrsOT12,");
        sb.Append("DayhrsOT13,");
        sb.Append("DayhrsOT14,");
        sb.Append("DayhrsOT15,");
        sb.Append("DayhrsHol1,");
        sb.Append("DayhrsHol2,");
        sb.Append("DayhrsHol3,");
        sb.Append("DayhrsHol4,");
        sb.Append("DayhrsHol5,");
        sb.Append("DayhrsHol6,");
        sb.Append("DayhrsHol7,");
        sb.Append("DayhrsHol8,");
        sb.Append("DayhrsHol9,");
        sb.Append("DayhrsHol10,");
        sb.Append("DayhrsHol11,");
        sb.Append("DayhrsHol12,");
        sb.Append("DayhrsHol13,");
        sb.Append("DayhrsHol14,");
        sb.Append("DayhrsHol15,");
        sb.Append("DayhrsHolOT1,");
        sb.Append("DayhrsHolOT2,");
        sb.Append("DayhrsHolOT3,");
        sb.Append("DayhrsHolOT4,");
        sb.Append("DayhrsHolOT5,");
        sb.Append("DayhrsHolOT6,");
        sb.Append("DayhrsHolOT7,");
        sb.Append("DayhrsHolOT8,");
        sb.Append("DayhrsHolOT9,");
        sb.Append("DayhrsHolOT10,");
        sb.Append("DayhrsHolOT11,");
        sb.Append("DayhrsHolOT12,");
        sb.Append("DayhrsHolOT13,");
        sb.Append("DayhrsHolOT14,");
        sb.Append("DayhrsHolOT15,");
        sb.Append("DayhrsSHol1,");
        sb.Append("DayhrsSHol2,");
        sb.Append("DayhrsSHol3,");
        sb.Append("DayhrsSHol4,");
        sb.Append("DayhrsSHol5,");
        sb.Append("DayhrsSHol6,");
        sb.Append("DayhrsSHol7,");
        sb.Append("DayhrsSHol8,");
        sb.Append("DayhrsSHol9,");
        sb.Append("DayhrsSHol10,");
        sb.Append("DayhrsSHol11,");
        sb.Append("DayhrsSHol12,");
        sb.Append("DayhrsSHol13,");
        sb.Append("DayhrsSHol14,");
        sb.Append("DayhrsSHol15,");
        sb.Append("DayhrsSHolOT1,");
        sb.Append("DayhrsSHolOT2,");
        sb.Append("DayhrsSHolOT3,");
        sb.Append("DayhrsSHolOT4,");
        sb.Append("DayhrsSHolOT5,");
        sb.Append("DayhrsSHolOT6,");
        sb.Append("DayhrsSHolOT7,");
        sb.Append("DayhrsSHolOT8,");
        sb.Append("DayhrsSHolOT9,");
        sb.Append("DayhrsSHolOT10,");
        sb.Append("DayhrsSHolOT11,");
        sb.Append("DayhrsSHolOT12,");
        sb.Append("DayhrsSHolOT13,");
        sb.Append("DayhrsSHolOT14,");
        sb.Append("DayhrsSHolOT15,");
        sb.Append("CreatedDate)");
        sb.Append("VALUES(");
        sb.Append("'" + timeEntry.TimeRangeRowId + "',");
        sb.Append("'" + timeEntry.EmployeeId + "',");
        sb.Append("'" + timeEntry.Day1 + "',");
        sb.Append("'" + timeEntry.Day2 + "',");
        sb.Append("'" + timeEntry.Day3 + "',");
        sb.Append("'" + timeEntry.Day4 + "',");
        sb.Append("'" + timeEntry.Day5 + "',");
        sb.Append("'" + timeEntry.Day6 + "',");
        sb.Append("'" + timeEntry.Day7 + "',");
        sb.Append("'" + timeEntry.Day8 + "',");
        sb.Append("'" + timeEntry.Day9 + "',");
        sb.Append("'" + timeEntry.Day10 + "',");
        sb.Append("'" + timeEntry.Day11 + "',");
        sb.Append("'" + timeEntry.Day12 + "',");
        sb.Append("'" + timeEntry.Day13 + "',");
        sb.Append("'" + timeEntry.Day14 + "',");
        sb.Append("'" + timeEntry.Day15 + "',");
        sb.Append("'" + timeEntry.OtDay1 + "',");
        sb.Append("'" + timeEntry.OtDay2 + "',");
        sb.Append("'" + timeEntry.OtDay3 + "',");
        sb.Append("'" + timeEntry.OtDay4 + "',");
        sb.Append("'" + timeEntry.OtDay5 + "',");
        sb.Append("'" + timeEntry.OtDay6 + "',");
        sb.Append("'" + timeEntry.OtDay7 + "',");
        sb.Append("'" + timeEntry.OtDay8 + "',");
        sb.Append("'" + timeEntry.OtDay9 + "',");
        sb.Append("'" + timeEntry.OtDay10 + "',");
        sb.Append("'" + timeEntry.OtDay11 + "',");
        sb.Append("'" + timeEntry.OtDay12 + "',");
        sb.Append("'" + timeEntry.OtDay13 + "',");
        sb.Append("'" + timeEntry.OtDay14 + "',");
        sb.Append("'" + timeEntry.OtDay15 + "',");
        sb.Append("'" + timeEntry.DayHol1 + "',");
        sb.Append("'" + timeEntry.DayHol2 + "',");
        sb.Append("'" + timeEntry.DayHol3 + "',");
        sb.Append("'" + timeEntry.DayHol4 + "',");
        sb.Append("'" + timeEntry.DayHol5 + "',");
        sb.Append("'" + timeEntry.DayHol6 + "',");
        sb.Append("'" + timeEntry.DayHol7 + "',");
        sb.Append("'" + timeEntry.DayHol8 + "',");
        sb.Append("'" + timeEntry.DayHol9 + "',");
        sb.Append("'" + timeEntry.DayHol10 + "',");
        sb.Append("'" + timeEntry.DayHol11 + "',");
        sb.Append("'" + timeEntry.DayHol12 + "',");
        sb.Append("'" + timeEntry.DayHol13 + "',");
        sb.Append("'" + timeEntry.DayHol14 + "',");
        sb.Append("'" + timeEntry.DayHol15 + "',");
        sb.Append("'" + timeEntry.DayhrsHolOT1 + "',");
        sb.Append("'" + timeEntry.DayhrsHolOT2 + "',");
        sb.Append("'" + timeEntry.DayhrsHolOT3 + "',");
        sb.Append("'" + timeEntry.DayhrsHolOT4 + "',");
        sb.Append("'" + timeEntry.DayhrsHolOT5 + "',");
        sb.Append("'" + timeEntry.DayhrsHolOT6 + "',");
        sb.Append("'" + timeEntry.DayhrsHolOT7 + "',");
        sb.Append("'" + timeEntry.DayhrsHolOT8 + "',");
        sb.Append("'" + timeEntry.DayhrsHolOT9 + "',");
        sb.Append("'" + timeEntry.DayhrsHolOT10 + "',");
        sb.Append("'" + timeEntry.DayhrsHolOT11 + "',");
        sb.Append("'" + timeEntry.DayhrsHolOT12 + "',");
        sb.Append("'" + timeEntry.DayhrsHolOT13 + "',");
        sb.Append("'" + timeEntry.DayhrsHolOT14 + "',");
        sb.Append("'" + timeEntry.DayhrsHolOT15 + "',");
        sb.Append("'" + timeEntry.DayhrsSHol1 + "',");
        sb.Append("'" + timeEntry.DayhrsSHol2 + "',");
        sb.Append("'" + timeEntry.DayhrsSHol3 + "',");
        sb.Append("'" + timeEntry.DayhrsSHol4 + "',");
        sb.Append("'" + timeEntry.DayhrsSHol5 + "',");
        sb.Append("'" + timeEntry.DayhrsSHol6 + "',");
        sb.Append("'" + timeEntry.DayhrsSHol7 + "',");
        sb.Append("'" + timeEntry.DayhrsSHol8 + "',");
        sb.Append("'" + timeEntry.DayhrsSHol9 + "',");
        sb.Append("'" + timeEntry.DayhrsSHol10 + "',");
        sb.Append("'" + timeEntry.DayhrsSHol11 + "',");
        sb.Append("'" + timeEntry.DayhrsSHol12 + "',");
        sb.Append("'" + timeEntry.DayhrsSHol13 + "',");
        sb.Append("'" + timeEntry.DayhrsSHol14 + "',");
        sb.Append("'" + timeEntry.DayhrsSHol15 + "',");
        sb.Append("'" + timeEntry.DayhrsSHolOT1 + "',");
        sb.Append("'" + timeEntry.DayhrsSHolOT2 + "',");
        sb.Append("'" + timeEntry.DayhrsSHolOT3 + "',");
        sb.Append("'" + timeEntry.DayhrsSHolOT4 + "',");
        sb.Append("'" + timeEntry.DayhrsSHolOT5 + "',");
        sb.Append("'" + timeEntry.DayhrsSHolOT6 + "',");
        sb.Append("'" + timeEntry.DayhrsSHolOT8 + "',");
        sb.Append("'" + timeEntry.DayhrsSHolOT9 + "',");
        sb.Append("'" + timeEntry.DayhrsSHolOT10 + "',");
        sb.Append("'" + timeEntry.DayhrsSHolOT11 + "',");
        sb.Append("'" + timeEntry.DayhrsSHolOT12 + "',");
        sb.Append("'" + timeEntry.DayhrsSHolOT13 + "',");
        sb.Append("'" + timeEntry.DayhrsSHolOT14 + "',");
        sb.Append("'" + timeEntry.DayhrsSHolOT15 + "',");
        sb.Append("'" + DateTime.Now + "')");
        EmployeeTimeEnrtyMapping = sb.ToString();
        ClassConnectionDb.ExecuteNonQuery(EmployeeTimeEnrtyMapping, CommandType.Text);

我会从您的访问数据库中选择数据并尝试将其放入列表中。

这是创建字符串列表的方式。

List<string> ListOfStrings = new List<string>();

这就是您将项目添加到列表的方式。

ListOfStrings.Add(StringVar)

这可能会让您了解如何做到这一点。怎么做。

目前尚不清楚您的目标是什么。 如果您尝试重复创建/插入一组记录 - - 其中将没有任何数据......这通常不是一个好的设计概念。

话虽如此 - 一种方法是手动设置一个用作模型的表。 然后使用追加查询插入模型表。

相关内容

  • 没有找到相关文章

最新更新