开发者

how to check whether the table is empty

hie all, i want to insert the data into the table only if the table is empty, so for that i need to check the condition to check whether data already exists in the table, if present then i want to empty the table before inserting the the fresh value. i know how to insert and delete the data only prob is to check the condition. so please can any help me out in this.

TO INSERT

Dim comUs开发者_如何学编程erSelect As OleDbCommand

        myDateTime(i) = DateTime.Parse(arr_dateTime(i))
        '  Console.WriteLine(r("P1"))
        Dim strSELEsCTa As Integer = r("P1")
        If ins < 10 Then
            ins = ins + 1

            Dim strSELECTa As String = "insert into tblvalues (DataTime ,P1) values ('" & DateTime.Parse(arr_dateTime(i)) & "','" & strSELEsCTa & "')"

            Dim dadte_s As New OleDbDataAdapter(strSELECTa, conn)
            comUserSelect = New OleDbCommand(strSELECTa, conn)

            comUserSelect.ExecuteNonQuery()
        End If

*TO DELETE *

 Dim strDelete As String = "delete * from tblvalues "

now i don know how to check the condition


"SELECT COUNT(*) FROM your_table_name"

If the table is empty, this should return 0.

Alternatively, you could try to select a row from the table and based on the response act upon it.

"SELECT * FROM your_table_name LIMIT 0, 1"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜