我有这个测试函数将一些示例数据插入表中。我想要的是关于手术成功的反馈。这是功能:
Public Function insertTest(ByVal userEmail As String) As Boolean
Dim result As Boolean = False
Try
Dim connection As New SqlConnection(connectionString)
connection.Open()
Dim sqlQuery As String = "insert into _TEST_activityLog values (@userEmail, 'delete', 'folder X')"
Dim command As New SqlClient.SqlCommand(sqlQuery, connection)
command.Parameters.Add("@userEmail", SqlDbType.VarChar).Value = userEmail
Dim rdr = command.ExecuteReader()
If rdr.HasRows Then
MsgBox("Record created successfully")
command.Dispose()
End If
rdr.Close()
command.Dispose()
connection.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
Return result
End Function
我尝试使用reader
部分,但它总是跳过它。顺便说一句,数据已成功插入数据库。
有人可以帮忙吗?