在VB.Net中使用MySQL存储函数进行SELECT

时间:2016-07-28 08:50:33

标签: mysql vb.net datagridview

我的数据库中有一个名为getItemQty()的存储函数。当我从localhost运行此代码时,它会加载数据。

     SELECT ItemId, CatalogNUmber, Cost, getItemQty(ItemId), 
     Minimum, Maximum, TypeId, SupplierId FROM items;

     Showing rows 0 - 24 (4387 total, Query took 2.4682 seconds.)

它在localhost中正常工作,但是当我将它应用于我的DataGridView时。它的加载需要永远,timeout expired. the timeout period elapsed显示。

继承我的代码以填充 DataGridView

            Dim command As New MySqlCommand()
            Dim cmdstring As String
            Dim adapter As New MySqlDataAdapter
            Dim dt As New DataTable
            cmdstring = "SELECT ItemId, CatalogNUmber, Cost, getItemQty(ItemId), Minimum, Maximum, TypeId, SupplierId FROM items;"
            With command
                .Connection = conn
                .CommandText = cmdstring
                .CommandTimeout = 60
            End With
            conn.Open()
            adapter.SelectCommand = command
            adapter.Fill(dt)
            dgvStocks.DataSource = dt
            command.Dispose()
            adapter.Dispose()
            conn.Close()

如何在localhost中加载 DataGridView 中的数据?如果它确定是什么导致这种加载?

0 个答案:

没有答案