Get number of rows in a SQL Server table in VB.NET

前端 未结 3 1202
太阳男子
太阳男子 2021-01-13 01:16

There are 10 rows in primary_student_table.

When I execute the following code, the result was -1.

Dim count As Int16
con.Open()
query =          


        
3条回答
  •  南笙
    南笙 (楼主)
    2021-01-13 01:51

    The solution is to replace

    count = cmd.ExecuteNonQuery
    

    with

    count = cmd.ExecuteScalar 
    

    Like Robert Beaubien said in his comments

提交回复
热议问题