DataList怎么绑定数据库和模糊查询?
我数据库中有张Test表里面有Title和ID2个字段,如何将其绑定到DataList上面,然后怎样才能进行模糊查询Title字段里面的类容?请大虾帮忙!...
我数据库中有张Test表 里面有Title和ID2个字段,如何将其绑定到DataList上面,然后怎样才能进行模糊查询Title字段里面的类容?
请大虾帮忙! 展开
请大虾帮忙! 展开
2个回答
2013-10-26
展开全部
在datalist旁边有个databind属性或是在视图中控件的右上角有个三角,点击即可,模糊查询,用like语句,like'% %'
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-10-26
展开全部
Public con As ADODB.Connection, Str As String, ado As ADODB.Recordset, sql As String
Public I As Integer, conn As String
Public Sub ado_Open()
Set con = New ADODB.Connection
conn = "Access"
If conn = "SQL" Then Str = "Driver={SQL SERVER};SERVER=192.168.1.168;Uid=SA;Pwd=;Database=tempdb"
If conn = "Access" Then Str = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & App.path & "\Finance.mdb;pwd=821001;ReadOnly=True"
If conn = "Excel" Then Str = "Driver={Microsoft Excel Driver (*.xls)};DBQ=" & App.path & "\xx.xls;ReadOnly=True"
con.Open Str
End Sub
Public Sub Newado()
Set ado = New ADODB.Recordset
ado.CursorLocation = adUseClient
ado.Open sql, con, adOpenDynamic, adLockBatchOptimistic
End Sub
Private Sub Form_Click()
ado_Open
sql = "select id2 from test where title like '%"& text1 &"%'"
Newado
DataList1.ListField = "id2"
Set DataList1.RowSource = ado
End Sub
Public I As Integer, conn As String
Public Sub ado_Open()
Set con = New ADODB.Connection
conn = "Access"
If conn = "SQL" Then Str = "Driver={SQL SERVER};SERVER=192.168.1.168;Uid=SA;Pwd=;Database=tempdb"
If conn = "Access" Then Str = "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & App.path & "\Finance.mdb;pwd=821001;ReadOnly=True"
If conn = "Excel" Then Str = "Driver={Microsoft Excel Driver (*.xls)};DBQ=" & App.path & "\xx.xls;ReadOnly=True"
con.Open Str
End Sub
Public Sub Newado()
Set ado = New ADODB.Recordset
ado.CursorLocation = adUseClient
ado.Open sql, con, adOpenDynamic, adLockBatchOptimistic
End Sub
Private Sub Form_Click()
ado_Open
sql = "select id2 from test where title like '%"& text1 &"%'"
Newado
DataList1.ListField = "id2"
Set DataList1.RowSource = ado
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询