2015-05-05 31 views
0

我试图在visual basic上创建一个DataGridView,但是我遇到了这个问题RowsCount行数不是整数的成员

这段代码加下划线的蓝色:

SQL.SQLDA.Fill(SQL.SQLDS, "GettingInfo").RowsCount 

它说RowsCount is not a member of integer.

这是所有过程的代码:

 Public Sub LoadBookingData() 
    Dim loadSQL As String = "SELECT * FROM booking" 
    Dim RowsCount As Integer 


    If SQL.SQLCon.State = ConnectionState.Closed Then 
     SQL.SQLCon.open() 
     SQL.SQLDA.Fill(SQL.SQLDS, "GettingInfo"). 
     RowsCount = SQL.SQLDS.Tables("GettingInfo").Rows.Count 
     If RowsCount < 1 Then 
      MsgBox("There is no records", MsgBoxStyle.Critical, "Sorry") 
      SQL.SQLDS.Reset() 
      SQL.SQLCon.Close() 
     Else 
      ' there are records ! 
      DGVData.Rows.Add(RowsCount) 
      For i As Integer = 0 To RowsCount - 1 
       With DGVData 
        .Rows(1).Cells(0).Value = SQL.SQLDS.Tables("GettingInfo").Rows(i).Item("bookingID") 
        .Rows(1).Cells(0).Value = SQL.SQLDS.Tables("GettingInfo").Rows(i).Item("paymentConfirmation") 
        .Rows(1).Cells(0).Value = SQL.SQLDS.Tables("GettingInfo").Rows(i).Item("totalCost") 
       End With 
      Next 
     End If 
     SQL.SQLDS.Reset() 
     SQL.SQLCon.Close() 

    Else 
     ' the connection is already open 
     SQL.SQLDA.Fill(SQL.SQLDS, "GettingInfo"). 
     RowsCount = SQL.SQLDS.Tables("GettingInfo").Rows.Count 
     If RowsCount < 1 Then 
      MsgBox("There is no records", MsgBoxStyle.Critical, "Sorry") 
      SQL.SQLDS.Reset() 
      SQL.SQLCon.Close() 
     Else 
      ' there are records ! 
      DGVData.Rows.Add(RowsCount) 
      For i As Integer = 0 To RowsCount - 1 
       With DGVData 
        .Rows(1).Cells(0).Value = SQL.SQLDS.Tables("GettingInfo").Rows(i).Item("bookingID") 
        .Rows(1).Cells(0).Value = SQL.SQLDS.Tables("GettingInfo").Rows(i).Item("paymentConfirmation") 
        .Rows(1).Cells(0).Value = SQL.SQLDS.Tables("GettingInfo").Rows(i).Item("totalCost") 
       End With 
      Next 
     End If 
     SQL.SQLDS.Reset() 
     SQL.SQLCon.Close() 
    End If 
End Sub 

这是SQLControl代码:

Imports System.Data.SqlClient 
    Public Class SQLControl 
      Public SQLCon As New SqlConnection With {.ConnectionString = "Data Source=JENNIFER\DDAP2015;Initial Catalog=zachtravelagency;Integrated Security=True;"} 
      Private SQLcmd As SqlCommand 
      Public SQLDA As SqlDataAdapter 
      Public SQLDS As DataSet 

有人能指出它为什么这么说吗?

+0

'SQL.SQLDA.Fill(SQL.SQLDS “GettingInfo”)'是一个方法(功能)返回一个整数(Intellisence会在你输入代码时告诉你这个),整数没有'RowCount'属性。 – Plutonix

回答

1

卸下线SQL.SQLDA.Fill(SQL.SQLDS, "GettingInfo").

它在VB.Net列为implicit line continuation的点.

+0

它不起作用。我已经删除了这个点,所以现在看起来像“SQL.SQLDA.Fill(SQL.SQLDS,”GettingInfo“)”现在它带来了一个警告框,说“NullReferenceException未处理”“对象引用未设置为目的”。 – Brooksie

+1

@Brooksie然后你有另一个问题,而不是你的问题。请使用调试器。 – Eric

+1

'点...是隐含的线延续'不,它不是(它也没有在链接中列出)。你是对的,有一个额外的尾随(这将防止编译代码),但你的理由是错误的。它执行范围解析。 – Plutonix