Public Class Form1
创新互联长期为近千家客户提供的网站建设服务,团队从业经验10年,关注不同地域、不同群体,并针对不同对象提供差异化的产品和服务;打造开放共赢平台,与合作伙伴共同营造健康的互联网生态环境。为西藏企业提供专业的成都网站制作、成都网站设计,西藏网站改版等技术服务。拥有10年丰富建站经验和众多成功案例,为您定制开发。
Private Function BindData(ByVal str As String) As DataTable
Dim conn As New OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\project\office\test.accdb")
Dim mtab As New DataTable
Dim adp As New OleDb.OleDbDataAdapter(str, conn)
mtab.Clear()
conn.Open()
adp.Fill(mtab)
conn.Close()
Return mtab
End Function
Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
Dim t As New DataTable
t = BindData("select * from Maintab")
ListBox1.DataSource = t
ListBox2.DataSource = t
ListBox1.DisplayMember = "a"
ListBox2.DisplayMember = "b"
End Sub
End Class
SELECT
PARSENAME(ip, 4) as part1,
PARSENAME(ip, 3) as part2,
PARSENAME(ip, 2) as part3,
PARSENAME(ip, 1) as part4,ip
from
ip地址表
参考:
parsename函数的用法
返回一个对像名特殊的部分,这此部分有对象名称,所有者,数据名,服务器名。注意:此函数不会直接判断特殊对象是否存在,它只返回给定特殊对像名称,要是找不到合适就返回NULL。
语法:
PARSENAME ( 'object_name' , object_piece )
'vs2010,VB10 牧固图
imports system.data
imports system.data.oledb
dim conn as OleDbConnection=new OleDbConnection
conn.ConnectionString= "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" Db ";Persist Security Info=True"
dim cmd as new sqlcommand
Dim cmd As OleDbCommand = New OleDbCommand
cmd.CommandText = "Select Name from Elements"
dim da as new OleDbDataAdapter
da.SelectCommand =cmd
dim ds as new Dataset
da.fill(ds)
conn.close
dim dt as datatable=ds.tables(0) '从数据库里面读出一列,放入了一个dataTable里面去。
'dt可以绑定到控件。如combobox
combo1.datasource=dt
combo1.displaymember="Name"