数据库方面的
看下面的句子
objcomm.commandtext= "select * from table_test "
textbox1.text=objcomm.executenonquery.tostring
且table_test表有5个数据,问?
为什么textbox1.test显示的是0呢?应该显示5啊?
[解决办法]
Public Class Form1
Dim conn As Data.OleDb.OleDbConnection
Dim comm As Data.OleDb.OleDbCommand
Dim dr As Data.OleDb.OleDbDataReader
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
conn = New OleDb.OleDbConnection( "Provider=Microsoft.Jet.OleDb.4.0;Data Source=D:\data.mdb ")
conn.Open()
comm = New OleDb.OleDbCommand
comm.Connection = conn
comm.CommandText = "SELECT * FROM 表1 "
dr = comm.ExecuteReader
Dim RecCount As Integer = 0
While dr.Read
RecCount += 1 ' 累加记录条数
End While
conn.Close()
MsgBox(RecCount)
End Sub
End Class