[求助]在datagridview中创建新表问题
我创建了三张表,要把这三张表的某些列重新排列创建另一张新表,新表是读取这三张表中列的数据的,同时在datagridview中显示出来,该如何写代码呢?最好可以有详细的例子,本人是菜鸟刚学~谢谢~
谢谢fairy4呀~~我按照你的方法创建了视图,在SQL查询中可以显示,但是为什么不可以在datagridview中显示呀~以下是我写的代码,可以帮我看看错在哪里吗
Private Sub binddata()
Dim dt_patient As DataTable = register.getdatatable("select 卡号,姓名,性别,年龄,身份证号,联系电话,住址 from patient order by 卡号")
Dim dt_guahao As DataTable = register.getdatatable("select 挂号类型,挂号时间 from guahao order by挂号类型")
Dim dt_login As DataTable = register.getdatatable("select username as '发卡人' from login order by username")
Dim dtnew As DataTable
Dim sqlada As New SqlClient.SqlDataAdapter
Dim sqlcmd As New SqlClient.SqlCommand("select *from patientsetview", register.sqlconn)
Dim ds As New DataSet
Try
sqlada.SelectCommand = sqlcmd
ds.Clear()
sqlada.Fill(ds)
Me.dgv0.DataSource = ds.Tables(0)
Me.dgv0.CurrentCell = dgv0.Rows(0).Cells(1)
Catch ex As Exception
writeerr(ex)
End Try
End Sub
Private Sub frmpi_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.binddata()
End Sub