vb怎么做才能把整个数据表显示出来呢?
我想用datagrid显示整个表,数据库是access就是select*fromJulorderbyinvno,里面有几个字段,我想把他们全部显示出来是用datagrid...
我想用datagrid显示整个表,数据库是access
就是 select * from Jul order by invno,里面有几个字段,我想把他们全部显示出来
是用datagrid吗?还是有什么别的方法?求详细步骤 展开
就是 select * from Jul order by invno,里面有几个字段,我想把他们全部显示出来
是用datagrid吗?还是有什么别的方法?求详细步骤 展开
展开全部
代码如下:
Public con As New SqlConnection("Data Source= ;Initial Catalog= ;User ID=sa;Password=sa;connect Timeout=15;Integrated Security=False;Persist Security Info=False")
Public constr As SqlDataAdapter
Public objdataset As DataSet
Try
If con.State = ConnectionState.Open Then
con.Close()
Else
con.Open()
strsql = "select * from Jul order by invno"
constr = New SqlDataAdapter(strsql, con)
objdataset = New DataSet
constr.Fill(objdataset, "Jul")
DataGrid1.DataSource = objdataset
DataGrid1.DataMember = "Jul"
con.Close()
End If
Catch ex As SqlException
MessageBox.Show(ex.Message)
Exit Try
End Try
Public con As New SqlConnection("Data Source= ;Initial Catalog= ;User ID=sa;Password=sa;connect Timeout=15;Integrated Security=False;Persist Security Info=False")
Public constr As SqlDataAdapter
Public objdataset As DataSet
Try
If con.State = ConnectionState.Open Then
con.Close()
Else
con.Open()
strsql = "select * from Jul order by invno"
constr = New SqlDataAdapter(strsql, con)
objdataset = New DataSet
constr.Fill(objdataset, "Jul")
DataGrid1.DataSource = objdataset
DataGrid1.DataMember = "Jul"
con.Close()
End If
Catch ex As SqlException
MessageBox.Show(ex.Message)
Exit Try
End Try
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询