将一个特定列的交替行显示到两个不同的列
我有一张表,其中包含字段 Empid、RecTime、EmpId 、Recdate。
这是代码: s = "从 HrEmployee e,AtdRecord a 中选择 e.EmpName,a.EmpId,a.WorkID,a.RecDate,a.RecTime,其中 a.EmpId=e.EmpId 且 EmpName='" & TextBox1.文本& "' 和 RecDate 之间 '" & TextBox2.文本& “'和'”& TextBox3.文本& "'"
cmd = New SqlCommand(s, conn)
cmd.ExecuteNonQuery()
da = New SqlDataAdapter(s, conn)
'ds = New DataSet 'da.Fill(ds)
dt = New DataTable()
da.Fill(dt)
dc1 = New DataColumn("InTime") ' make column InTime and OutTime
dc2 = New DataColumn("OutTime")
dt.Columns.Add(dc1)
dt.Columns.Add(dc2)
'For entering data from database col to datatable (Intime,Outtime)
For Each dr In dt.Rows
i = 4
mystring = dr(i)
timestring = dt.Rows.IndexOf(dr)
If timestring Mod 2 = 0 Then
j = 5
dr(j) = mystring
Else
k = 6
dr("OutTime") = mystring
End If
Next
For Each col In dt.Columns
bfield = New BoundField
bfield.DataField = col.ColumnName
bfield.HeaderText = col.ColumnName
'GridView1.Columns.Add(bfield)
Next
GridView1.DataSource = dt
GridView1.DataBind()
conn.Close()
我想知道如何从 RecTime 获取这种情况下的值:
InTime Outtime
8 9
1:30 2:45
当 RecTime:
8
9
1:30
2:45
I have one table having field Empid,RecTime,EmpId ,Recdate.
Here is the code:
s = "Select e.EmpName,a.EmpId,a.WorkID,a.RecDate,a.RecTime from HrEmployee e,AtdRecord a where a.EmpId=e.EmpId and EmpName='" & TextBox1.Text & "' and RecDate between '" & TextBox2.Text & "' and '" & TextBox3.Text & "'"
cmd = New SqlCommand(s, conn)
cmd.ExecuteNonQuery()
da = New SqlDataAdapter(s, conn)
'ds = New DataSet 'da.Fill(ds)
dt = New DataTable()
da.Fill(dt)
dc1 = New DataColumn("InTime") ' make column InTime and OutTime
dc2 = New DataColumn("OutTime")
dt.Columns.Add(dc1)
dt.Columns.Add(dc2)
'For entering data from database col to datatable (Intime,Outtime)
For Each dr In dt.Rows
i = 4
mystring = dr(i)
timestring = dt.Rows.IndexOf(dr)
If timestring Mod 2 = 0 Then
j = 5
dr(j) = mystring
Else
k = 6
dr("OutTime") = mystring
End If
Next
For Each col In dt.Columns
bfield = New BoundField
bfield.DataField = col.ColumnName
bfield.HeaderText = col.ColumnName
'GridView1.Columns.Add(bfield)
Next
GridView1.DataSource = dt
GridView1.DataBind()
conn.Close()
I want to know how can i get the values in this scenario from RecTime:
InTime Outtime
8 9
1:30 2:45
When RecTime:
8
9
1:30
2:45
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论