0

I'm trying to create an DataGridView on visual basic, however I'm having a problem with this RowsCount.

This code is underlined blue:

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

It says RowsCount is not a member of integer.

This is all of the code for the process:

      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

This is the code for 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

Can someone point out why it is saying this?

ɐsɹǝʌ ǝɔıʌ
  • 4,440
  • 3
  • 35
  • 56
Brooksie
  • 27
  • 8
  • `SQL.SQLDA.Fill(SQL.SQLDS, "GettingInfo")` is a method (function) returning an integer (Intellisence will tell you this as you type the code), and integer does not have a `RowCount` property. – Ňɏssa Pøngjǣrdenlarp May 05 '15 at 13:16

1 Answers1

1

Remove the dot . of the line SQL.SQLDA.Fill(SQL.SQLDS, "GettingInfo").

It is classified as implicit line continuation in VB.Net

Eric
  • 5,675
  • 16
  • 24
  • it doesn't work. I have removed the dot so now it looks like "SQL.SQLDA.Fill(SQL.SQLDS, "GettingInfo")" And now it brings up a warning box saying "NullReferenceException was unhandled" "Object reference not set to an instance of an object". – Brooksie May 05 '15 at 10:09
  • 1
    @Brooksie Then you have another issue other than your question. Please use debugger. – Eric May 05 '15 at 10:12
  • 1
    `the dot ... is implicit line continuation` no it is not (nor is it listed in the link). You're right that there is an extra trailing one (which would prevent to code from compiling), but your reason is wrong. It performs scope resolution. – Ňɏssa Pøngjǣrdenlarp May 05 '15 at 13:23
  • @Plutonix Thanks, just think if it is `After a member qualifier character (.) ...` – Eric May 06 '15 at 01:25