统计记录
Dim Ston As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Application.StartupPath + "\vb1\KScount.mdb;Persist Security Info=False"
Dim myConn As New OleDbConnection(Ston)
myConn.Open()
Dim Strcom As String = "select * from Tcount"
Dim myComd As New OleDb.OleDbDataAdapter(Strcom, myConn)
Dim mydataset As New DataSet
myComd.Fill(mydataset, "Tcount")
Dim consum1 As Single
Dim consum2 As Single
If mydataset.Tables(0).Rows.Count > 0 Then
Dim strcom1 As String = "select sum(val(西药费)),sum(val(中草药)) from Tcount" '这两个字段是字符型的,要转换下
Dim myCommand As New OleDb.OleDbCommand(strcom1, myConn)
Dim rd As OleDbDataReader = myCommand.ExecuteReader
Do While rd.Read
Try
consum1 = rd.GetValue(0)
consum2 = rd.GetValue(1)
Catch
MsgBox(Err.Description)
End Try
Loop
End If
myConn.Close()
myComd.Dispose()
TextBox24.Text = consum1
TextBox25.Text = consum2
[此贴子已经被作者于2017-8-18 08:56编辑过]