我制作了代码vb net,可以以我的形式显示,我使用数据集调用数据,我的编码如下
Public Function GetTableRow(ByVal strsql As String) As DataSet
Dim conn As New SqlConnection
Dim sDa As New SqlDataAdapter(strsql, conn)
Dim ds As New DataSet
Try
sDa.Fill(ds)
Catch ex As Exception
End Try
sDa.Dispose()
Return ds
End Function
Private Sub CmRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmRefresh.Click
Dim ds As New DataSet
Dim conn = "server='server'; database='database'; user=user;password='password';"
Dim strsql As String = "exec spSPDMonStockProductHarian '" & 230 & "'"
ds = conn.GetTableRow(strsql)
With Listdata
.DataSource = ds.Tables(0)
End With
Koneksi.Close()
Koneksi.Close()
End Sub
我执行此程序时的问题,错误消息
"Public member 'Function' on type 'String' not found."
我没有得到什么问题,所以任何解决方案都会欣赏!!
答案 0 :(得分:0)
你应该这样试试:
Private Sub CmRefresh_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmRefresh.Click
Dim ds As New DataSet
Dim conn As String = "server='server'; database='database'; user=user;password='password';"
Dim strsql As String = "exec spSPDMonStockProductHarian '" & 230 & "'"
ds = GetTableRow(strsql)
If ds.Tables.Count > 0 Then
With Listdata
.DataSource = ds.Tables(0)
End With
Else
MessageBox.Show("Dataset is empty")
End If
Koneksi.Close()
Koneksi.Close()
End Sub
我在这里做了改变:
Dim conn As String
和
ds = GetTableRow(strsql)
基本上,GetTableRow
是您的自定义函数,它未在类string
中定义。