-6
我试图做与SQL Server CE数据库的记录排列,但我每次都有不同的结果,特别是对于20选择5 = 15504如何在SQL Server CE数据库中插入多行?
我已经做了5循环在C#内相互读取日期从一个表
for(int i=1;i<n;i++)
{
for (acv1=1; acv1 <= n; acv1++)
{
string sql = "SELECT PId,DateOFVisit,RaId,VisitNum from tblPatientVisit";
visit1 = new ArrayList();
if (id > 0)
{
sql += "\n where PId= " + id + "AND VisitNum=" + acv1;
}
try
{
SqlCeCommand cm1 = new SqlCeCommand(sql, f.conn);
SqlCeDataAdapter da1 = new SqlCeDataAdapter(cm1);
DataTable dt1 = new DataTable();
da1.Fill(dt1);
foreach (DataRow dr in dt1.Rows)
{
visit1.Add(dr["VisitNum"].ToString());
visit1.Add(dr["PId"].ToString());
visit1.Add(p_name);
visit1.Add(dr["DateOfVisit"].ToString());
visit1.Add(description(Convert.ToInt32(dr["RaId"])));
break;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
for(int x=i+1;x<n;x++)
{
// select statement here for x and stored it on array list b
for(int y=x+1;y<n;y++)
{
// select statement here for y and stored it on array list c
for(intz=y+1;z<n;z++)
{
// select statement here for z and stored it on array list d
for(int t=z+1;z<n;z++)
{
// select statement here for t and stored it on array list e
// in order to insert the array lists in order but i got different result than I expected
}
}
}
}
}
我想这样
1 2 3 4 5
1 2 3 4 6
1 2 3 4 7
1 2 3 4 8
1 2 3 4 9
1 2 3 4 10
1 2 3 4 11
1 2 3 4 12
1 2 3 4 13
结果等到
16 17 18 19 20
我已经从代码得到上述这样
16 2 4 6 10
编辑:
我有20条记录上tblACV
,我想读这条记录,并进行排列的记录和存储他们又到另一个表
我不能跟随你在做什么。请清理你的格式,不要排除“select statement here”代码。你最终的目标是什么?不要只告诉我们你在做什么 - 也请告诉我们你想做什么。可能有更好的方法。 –
我做了一些编辑,使其明确 –
这并没有让它更清晰 - 拖曳大括号的负载点是什么! – DaveRlz