刷新数据 - 存储过程

时间:2017-07-24 13:13:45

标签: sql-server vb.net stored-procedures refresh

我需要帮助为我的存储过程进行自动刷新,并使用新信息填充数据表。我需要建议,我试图使用Timer清除数据表并再次执行存储过程,但我认为这是一个不好的解决方案。

我目前的代码:

 Public Sub Efficiency_Procedure()
    _eff.Clear()
    Dim dtStart As String

    dtStart = FormatDateTime(DateTime.Today)

    Dim cmd As New SqlCommand("spEfficiencyConfB", MyConnection)
    Dim outParam As SqlParameter
    cmd.CommandType = CommandType.StoredProcedure
    cmd.Parameters.Add("@startTime", SqlDbType.DateTime).Value = dtStart
    cmd.Parameters.Add("@stopTime", SqlDbType.DateTime).Value = dtStart
    outParam = cmd.Parameters.Add("@nrOut", SqlDbType.Int)
    outParam.Direction = ParameterDirection.Output

    If MyConnection.State = ConnectionState.Closed Then
        MyConnection.Open()
    End If

    Dim dr As SqlDataReader = cmd.ExecuteReader(CommandBehavior.SequentialAccess)

    _eff.Load(dr)

    dr.Close()
    cmd.Dispose()

    If MyConnection.State = ConnectionState.Open Then
        MyConnection.Close()
    End If
End Sub

谢谢

0 个答案:

没有答案