情况:
表单 - 包含 dataGridView(需要填充)
类——应该包含所有的填充过程
我在课堂上做什么?
Public Function prodcatgetdata(ByVal cmd As String) As DataTable
Try
Dim command As New SqlCommand(cmd)
Dim dsprodcat As New DataSet
Dim cn1 As New SqlConnection("data source =SC\SQLEXPRESS;initial catalog=mydb;integrated security=true")
Dim daprodcat As New SqlDataAdapter(selectprodcat, cn1)
cn1.Open()
'daprodcat.SelectCommand = cmd
daprodcat.Fill(dsprodcat)
Return dsprodcat.Tables("m_prodcat")
cn.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Function
我在 formload() 中做什么?
prodcatcls.prodcatgetdata(selectprodcat)
我哪里错了?