2016-12-06 97 views
0

这很奇怪,我有一个网格工作,并显示它需要什么,两个不是,他们都写同样的方式。DataGridView不显示数据VB.NET

Private Sub Form2_Shown(sender As Object, e As EventArgs) Handles Me.Shown 
    access.ExecQuery("SELECT emotion1,emotion2,emotion3,emotion4,emotion5, " & _ 
        "situation1,situation2,situation3, " & _ 
        "physical1,physical2,physical3,physical4,physical5 " & _ 
        "FROM emotionlogdb ORDER BY id DESC;") 
    If Not String.IsNullOrEmpty(access.exception) Then 
     MsgBox(access.exception) : Exit Sub 
    End If 
    DataGridView1.DataSource = access.DBDT 

End Sub 

以及不两个代码:

Private Sub Form5_Shown(sender As Object, e As EventArgs) Handles Me.Shown 
    access.ExecQuery("SELECT journal FROM journalDB ORDER BY id DESC") 
    If Not String.IsNullOrEmpty(access.exception) Then 
     MsgBox(access.exception) : Exit Sub 
    End If 
    DataGridView1.DataSource = access.DBDT 
End Sub 

和:

Private Sub Form6_Shown(sender As Object, e As EventArgs) Handles MyBase.Load 
    Dim sit As Integer = Alg.sitMode 
    Dim em As Integer = Alg.emMode 

    Access.ExecQuery("SELECT EmPlusSitMemo FROM TrendsDB WHERE EmotionID1= " & em & "AND SitID1= " & sit & ";") 
    If Not String.IsNullOrEmpty(Access.exception) Then 
     MsgBox(Access.exception) : Exit Sub 
    End If 
    DataGridView1.DataSource = Access.DBDT 
End Sub 

我在做什么错,工程

码?

回答

0

你需要尝试什么是把一个断点以下行:

access.ExecQuery("SELECT journal FROM journalDB ORDER BY id DESC") 

Access.ExecQuery("SELECT EmPlusSitMemo FROM TrendsDB WHERE EmotionID1= " & em & "AND SitID1= " & sit & ";") 

,然后运行在调试模式下您的项目。如果您使用MS Visual Studio,则需要按F5键。但是您还需要将解决方案配置设置为调试(以启用调试符号的生成)而不是发布。

当您在调试模式下启动您的应用程序时,会生成必要的用户活动(即单击链接,按钮)以到达显示这两个非工作空白表单的地方。如果您设法提升Form5_Shown或Form6_Shown事件,则调试器将停止在您设置的断点处。

然后按F10(如果您使用的是Visual Stuido,请再次查看),并查看您的数据库的SQL查询是否无例外地执行。也许你拼错了字段名称或表名。