如何让DATAGIRD中显示我想要的几列数据?
如题所示。
这是我在DATAGIRD中显示数据的代码。把全部数据都显示了,但是我只需要几列数据,应该怎么改下?
Private Sub Command1_Click()
Dim strSQL As String
Dim strCon(4) As String
Dim intCount As Integer
Dim i As Integer
intCount = 0
'获得所有得查询条件
If Text1.Text <> "" Then
If Check1.Value = 1 Then
strCon(1) = "船型 like '%" & Text1.Text & "%'"
Else
strCon(1) = "船型='" & Text1.Text & "'"
End If
Else
strCon(1) = ""
End If
If Text2.Text <> "" Then
If Check1.Value = 1 Then
strCon(2) = "产品号 like '%" & Text2.Text & "%'"
Else
strCon(2) = "产品号='" & Text2.Text & "'"
End If
Else
strCon(2) = ""
End If
If Text3.Text <> "" Then
If Check1.Value = 1 Then
strCon(3) = "图号 like '%" & Text3.Text & "%'"
Else
strCon(3) = "图号='" & Text3.Text & "'"
End If
Else
strCon(3) = ""
End If
If Text4.Text <> "" Then
If Check1.Value = 1 Then
strCon(3) = "零件号 like '%" & Text4.Text & "%'"
Else
strCon(3) = "零件号='" & Text4.Text & "'"
End If
Else
strCon(3) = ""
End If
If strCon(1) = "" And strCon(2) = "" And strCon(3) = "" And strCon(4) = "" Then
strSQL = "select * from xinxi"
Else
strSQL = "select * from xinxi where "
For i = 1 To 4
If strCon(i) <> "" Then
intCount = intCount + 1
If intCount = 1 Then
strSQL = strSQL + strCon(i)
Else
strSQL = strSQL + " and " + strCon(i)
End If
End If
Next
End If
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb;Persist Security Info=False"
Adodc1.CursorLocation = adUseClient
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = strSQL
Adodc1.Refresh
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim db As New ADODB.Connection
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb;Persist Security Info=False"
db.ConnectionString = Adodc1.ConnectionString
If db.State <> ADODB.ObjectStateEnum.adStateClosed Then db.Close
db.Open
End Sub
根据上面的查询条件,我只想要我想要几列数据,该如何搞
这是我在DATAGIRD中显示数据的代码。把全部数据都显示了,但是我只需要几列数据,应该怎么改下?
Private Sub Command1_Click()
Dim strSQL As String
Dim strCon(4) As String
Dim intCount As Integer
Dim i As Integer
intCount = 0
'获得所有得查询条件
If Text1.Text <> "" Then
If Check1.Value = 1 Then
strCon(1) = "船型 like '%" & Text1.Text & "%'"
Else
strCon(1) = "船型='" & Text1.Text & "'"
End If
Else
strCon(1) = ""
End If
If Text2.Text <> "" Then
If Check1.Value = 1 Then
strCon(2) = "产品号 like '%" & Text2.Text & "%'"
Else
strCon(2) = "产品号='" & Text2.Text & "'"
End If
Else
strCon(2) = ""
End If
If Text3.Text <> "" Then
If Check1.Value = 1 Then
strCon(3) = "图号 like '%" & Text3.Text & "%'"
Else
strCon(3) = "图号='" & Text3.Text & "'"
End If
Else
strCon(3) = ""
End If
If Text4.Text <> "" Then
If Check1.Value = 1 Then
strCon(3) = "零件号 like '%" & Text4.Text & "%'"
Else
strCon(3) = "零件号='" & Text4.Text & "'"
End If
Else
strCon(3) = ""
End If
If strCon(1) = "" And strCon(2) = "" And strCon(3) = "" And strCon(4) = "" Then
strSQL = "select * from xinxi"
Else
strSQL = "select * from xinxi where "
For i = 1 To 4
If strCon(i) <> "" Then
intCount = intCount + 1
If intCount = 1 Then
strSQL = strSQL + strCon(i)
Else
strSQL = strSQL + " and " + strCon(i)
End If
End If
Next
End If
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb;Persist Security Info=False"
Adodc1.CursorLocation = adUseClient
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = strSQL
Adodc1.Refresh
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Form_Load()
Dim db As New ADODB.Connection
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\db1.mdb;Persist Security Info=False"
db.ConnectionString = Adodc1.ConnectionString
If db.State <> ADODB.ObjectStateEnum.adStateClosed Then db.Close
db.Open
End Sub
根据上面的查询条件,我只想要我想要几列数据,该如何搞
...全文
相关推荐
EasyUI学习之DataGird分页显示数据
在本文中,我们将深入探讨如何使用EasyUI的DataGird组件实现分页显示数据。
easyui datagird增删改分页例子
**DataGrid**:EasyUI的DataGrid组件可以显示大量数据,支持分页加载,减少一次性加载的数据量,提高页面性能。同时,它能与后端进行交互,实现增删改操作。7.
Datagird增改删例子
DataTable可以看作内存中的数据表,它可以被设置为DataGridView的数据源,从而将数据库中的数据显示在界面上。
FLEX中DATAgird的学习
例如,如果你想要一个静态显示的 `Label`,即使在非编辑状态下也能显示数据,可以设置 `itemRenderer`。
flex通过httpService读取xml数据到datagird中
该项目使用Adobe Flex通过HTTPService组件请求并加载本地XML数据文件,将书店及图书信息解析后动态显示在DataGrid控件中。核心功能涉及Flex前端数据绑定、异步HTTP通信与X


数据库(包含打印,安装,报表)
