//下面的代码是我用asp.net写的读取数据的程序段<br><br> Dim myStr, myStr1, myStr2 As String<br> Dim myIndex As Integer<br> Dim myArray1(24, 2), myArray2(48, 2) As String<br> Dim myStrings As StringBuilder<br> Dim I, J, K As Integer<br><br> myIndex = RList1.SelectedValue<br> For I = 0 To 23<br> myArray1(I, 0) = I & ":00:00"<br> myArray1(I, 1) = I & ":59:59"<br> Next I<br> J = 0<br> For I = 0 To 23<br> myArray2(J, 0) = I & ":00:00"<br> myArray2(J, 1) = I & ":29:59"<br> J = J + 1<br> myArray2(J, 0) = I & ":30:00"<br> myArray2(J, 1) = I & ":59:59"<br> J = J + 1<br> Next<br> myStrings = New StringBuilder<br> myCommand = New SqlClient.SqlCommand("select distinct(floattable.tagindex) as tagindex from floattable,tagtable where floattable.tagindex=tagtable.tagindex order by tagtable.tagindex", myConn)<br> If myConn.State.ToString() = "open" Then<br> myConn.Close()<br> End If<br> myConn.Open()<br> myReader = myCommand.ExecuteReader<br> J = 0<br> While myReader.Read()<br> myStrings.Append("(select top 1 isnull(val,0) from floattable where dateandtime=a.dateandtime and tagindex=" & Trim(myReader("tagindex"
) & " order by dateandtime desc) as val" & J & ","
<br> J = J + 1<br> End While<br> myConn.Close()<br> myStr2 = myStrings.ToString().Substring(0, myStrings.ToString().Length - 1)<br> If myIndex = 0 Then<br> K = 23<br> Else<br> K = 47<br> End If<br> J = 0<br> For J = 0 To K<br> If myConn.State.ToString() = "Open" Then<br> myConn.Close()<br> End If<br> myConn.Open()<br> If myIndex = 0 Then<br> myStr1 = "select top 1 dateandtime," & myStr2 & " from floattable a where convert(varchar,dateandtime,120)>='" & TextBox1.Text & " " & myArray1(J, 0) & "' and convert(varchar,dateandtime,120)<='" & TextBox1.Text & " " & myArray1(J, 1) & "' order by dateandtime desc"<br> End If<br> If myIndex = 1 Then<br> myStr1 = "select top 1 dateandtime," & myStr2 & " from floattable a where convert(varchar,dateandtime,120)>='" & TextBox1.Text & " " & myArray2(J, 0) & "' and convert(varchar,dateandtime,120)<='" & TextBox1.Text & " " & myArray2(J, 1) & "' order by dateandtime desc"<br> End If<br> myCommand = New SqlClient.SqlCommand(myStr1, myConn)<br> myCommand = New SqlClient.SqlCommand(myStr1, myConn)<br> myReader = myCommand.ExecuteReader<br> If myIndex = 0 Then<br> Response.Write(myArray1(J, 1))<br> Else<br> Response.Write(myArray2(J, 1))<br> End If<br> Response.Write(" "
<br> While myReader.Read()<br> Response.Write(myReader("dateandtime"
& " "
<br> For I = 1 To myReader.FieldCount - 1<br> Response.Write(Decimal.Parse(String.Format("{0:F2}", Val(myReader(I)))) & " "
<br> Next<br> End While<br> myConn.Close()<br> Response.Write("<br>"
<br> Next J