你好.能问你个关于VB.NET的问题吗?
定义了一个类:类的名称为:DataBinding.vb其代码如下:NamespaceTechBookPublicClassDataBindingPublicSharedS...
定义了一个类:类的名称为:DataBinding.vb 其代码如下:
Namespace TechBook
Public Class DataBinding
Public Shared Sub FillSistView(ByRef lsv As ListView, ByVal tableName As String, ByVal num As Integer, ByVal connStr As String, _
Optional ByVal field As String = "", Optional ByVal op As String = "=", Optional ByVal value As String = "")
lsv.Items.Clear()
Dim SQLString As String = "SELECT * FROM " & tableName
If field <> "" Then
SQLString += " Where " & field & op & value
End If
Dim dt As DBDataTable = New DBDataTable(connStr)
Dim table As DataTable = dt.CreateDataTable(SQLString, tableName)
Dim UserRow As DataRow
Dim lItem As ListViewItem
For Each UserRow In table.Rows
lItem = New ListViewItem(UserRow(0).ToString())
Dim i As Integer
For i = 1 To num - 1
lItem.SubItems.Add(UserRow(i))
Next
lsv.Items.Add(lItem)
Next
End Sub
End Class
End Namespace
在程序调用这个类时,总是出错:出错的提示为:未声明名称DataBingding.
程序的代码如下:
Public Class frmSearchProduct
Private Shared ConnStr As String = "Server=Tony;DataBase=Super;Integrated Security=SSPI"
Private Sub frmSearchProduct_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DataBinding.FillSistView(ListView1, "Product", 9, ConnStr)
RadioButton1.Checked = True
TextBox1.Select()
End Sub
Private Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Dim strField As String
Dim strValue As String
If RadioButton1.Checked Then
strField = "编号"
strValue = "" & TextBox1.Text & "'"
Else
strField = "供货商编号子"
strValue = "'" & TextBox1.Text & "'"
End If
ListView1.Items.Clear()
DataBinding.FillSistView(ListView1, "Product", 9, ConnStr, strField, "=", strValue)
End Sub
End Class
请问一下问题出在哪里?
请帮忙,在下先谢谢了. 展开
Namespace TechBook
Public Class DataBinding
Public Shared Sub FillSistView(ByRef lsv As ListView, ByVal tableName As String, ByVal num As Integer, ByVal connStr As String, _
Optional ByVal field As String = "", Optional ByVal op As String = "=", Optional ByVal value As String = "")
lsv.Items.Clear()
Dim SQLString As String = "SELECT * FROM " & tableName
If field <> "" Then
SQLString += " Where " & field & op & value
End If
Dim dt As DBDataTable = New DBDataTable(connStr)
Dim table As DataTable = dt.CreateDataTable(SQLString, tableName)
Dim UserRow As DataRow
Dim lItem As ListViewItem
For Each UserRow In table.Rows
lItem = New ListViewItem(UserRow(0).ToString())
Dim i As Integer
For i = 1 To num - 1
lItem.SubItems.Add(UserRow(i))
Next
lsv.Items.Add(lItem)
Next
End Sub
End Class
End Namespace
在程序调用这个类时,总是出错:出错的提示为:未声明名称DataBingding.
程序的代码如下:
Public Class frmSearchProduct
Private Shared ConnStr As String = "Server=Tony;DataBase=Super;Integrated Security=SSPI"
Private Sub frmSearchProduct_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
DataBinding.FillSistView(ListView1, "Product", 9, ConnStr)
RadioButton1.Checked = True
TextBox1.Select()
End Sub
Private Sub btnSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSearch.Click
Dim strField As String
Dim strValue As String
If RadioButton1.Checked Then
strField = "编号"
strValue = "" & TextBox1.Text & "'"
Else
strField = "供货商编号子"
strValue = "'" & TextBox1.Text & "'"
End If
ListView1.Items.Clear()
DataBinding.FillSistView(ListView1, "Product", 9, ConnStr, strField, "=", strValue)
End Sub
End Class
请问一下问题出在哪里?
请帮忙,在下先谢谢了. 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询