Advertisement

06.06.2007 at 05:51AM PDT, ID: 22616147
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.6

VB.net Display additional fields in Datagrid.

Asked by thomashospital in .NET, Miscellaneous Programming

Tags: , ,

How can I display more fields in my dataGrid.  I am able to display the accno but I want to be able to display other fields from my query. I am reading from an array into the datagrid, and here is my code.
Imports System.Data.sqlclient
Public Class Census

    Public CNTR As Integer = 0
    ' Public ArrayOfAccounts(100000) As String
    Public ArrayOfAccounts(100000) As Account







    Function GetLastDay(ByVal aDate)

        'Sets any date value to be the last day of the month
        Dim dteFirstDayNextMonth
        'dateValue = dteFirstDayNextMonth
        dteFirstDayNextMonth = DateSerial(Year(aDate), Month(aDate) + 1, 1)
        'GetLastDay = Day(DateAdd("d", -1, dteFirstDayNextMonth))
        GetLastDay = DateSerial(Year(aDate), Month(aDate) + 1, 1 - 1)

    End Function


    Private Sub btnStart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnStart.Click
        ' Build a connection to thomasdata table
        ' and populate the datareader with patient days
        '------------------------------------------------
        'Dim DA_PatientDaysDlyCY As SqlDataAdapter
        Dim CurrentDate As String
       
        Dim cmbBoxVar As String
        Dim theMonth As String

        'Put things together for a date text value
        theMonth = cmbDateRange.SelectedValue

        'Uses microsofts calendar to take care of leap year
        Dim theYear As String = Year(Today)
        cmbBoxVar = theMonth + "/" + "01/" + theYear
        ' MsgBox(cmbBoxVar)

        'Switch the month value to the last day of the month by calling the GetLastDay Func  
        'This should take care of leap years
        CurrentDate = GetLastDay(cmbBoxVar)

        'MsgBox(CurrentDate)

        Dim dateBack As Date
        'Dim dateBack2 As String

        dateBack = DateAdd("d", -90, CurrentDate)
        'dateBack2 = dateBack
        'MsgBox(dateBack2)


        'Dim tempdate As Date = dateBack2
        Dim exitloop As Boolean
        exitloop = False

        Do While exitloop = False
            'MsgBox(dateBack)
            dateBack = DateAdd("d", 1, dateBack)
            Call acctLookUp(dateBack)

            If dateBack = CurrentDate Then
                exitloop = True
            End If
        Loop
        ' MsgBox(ArrayOfAccounts)
        'Array.Sort(ArrayOfAccounts)




        ' Build a new array without duplicates
        Call mysub()

        'myArray.Sort()
        'MsgBox(myArray.ToString)


        'Dim source As New BindingSource
        'source.DataSource = myArray.ToString
        'dgridView.DataSource = source




    End Sub

    Private Sub acctLookUp(ByVal tempdate As Date)
        'Query data to get ready to put into a sql table
        Dim Conn_PatientDaysDlyCY As SqlConnection
        Dim SqlSelect_PatientDaysDlyCY As SqlCommand
        Dim DS As New DataSet()
        Dim myreaderCY As SqlDataReader
        Dim ConnString As String = "*************************************************************"
        Dim SelectStatementCY As String = "SELECT acctno, svc FROM vw_ThomasData" + _
                                          " WHERE (admdate <= '" + tempdate + "' and  + admdate <> '01/01/1900') " + _
                                          "And (disdate > '" + tempdate + "' Or disdate = '01/01/1900') " + _
                                          "And (svc = 'PSY' or svc = 'BHC') and totalrev <> 0" + _
                                          " ORDER BY vw_ThomasData.admdate"




        'Create SQL adaptor and populate it
        Dim adaptor As SqlDataAdapter = New SqlDataAdapter(SelectStatementCY, ConnString)
        Dim cmdBuilder As SqlCommandBuilder = New SqlCommandBuilder(adaptor)

        Conn_PatientDaysDlyCY = New SqlConnection(ConnString)
        Conn_PatientDaysDlyCY.Open()
        SqlSelect_PatientDaysDlyCY = New SqlCommand(SelectStatementCY, Conn_PatientDaysDlyCY)
        myreaderCY = SqlSelect_PatientDaysDlyCY.ExecuteReader
        adaptor.Fill(DS)


        'old loop through data
        'For I = 0 To DS.Tables(0).Rows.Count - 1
        '    'MsgBox(DS.Tables(0).Rows(I).Item(0))
        '    'DS.Tables(0).Rows(I).Item(1) = 0
        '    ArrayOfAccounts(CNTR) = DS.Tables(0).Rows(I).Item(0)
        '    'trying to populate the dgridView for testing purposes
        '    CNTR = CNTR + 1
        'Next


        'loop through the records and load into array
        Dim I As Integer

        For I = 0 To DS.Tables(0).Rows.Count - 1
            'MsgBox(DS.Tables(0).Rows(I).Item(0))
            'DS.Tables(0).Rows(I).Item(1) = 0
            Dim acc As New Account(DS.Tables(0).Rows(I).Item(1).ToString())
            ArrayOfAccounts(CNTR) = acc
            CNTR = CNTR + 1
        Next

        'send array values using arrayOfAccounts Class to the DataGrid
        dgridView.DataSource = ArrayOfAccounts

        'Close Connection
        Conn_PatientDaysDlyCY.Close()



    End Sub

 

    Private Sub Census_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        'Populate the Combo Box
        Dim list As New ArrayList()
        list.Add(New DictionaryEntry("January", "01"))
        list.Add(New DictionaryEntry("February", "02"))
        list.Add(New DictionaryEntry("March", "03"))
        list.Add(New DictionaryEntry("April", "04"))
        list.Add(New DictionaryEntry("May", "05"))
        list.Add(New DictionaryEntry("June", "06"))
        list.Add(New DictionaryEntry("July", "07"))
        list.Add(New DictionaryEntry("August", "08"))
        list.Add(New DictionaryEntry("September", "09"))
        list.Add(New DictionaryEntry("October", "10"))
        list.Add(New DictionaryEntry("November", "11"))
        list.Add(New DictionaryEntry("December", "12"))

        Me.cmbDateRange.DataSource = list
        Me.cmbDateRange.DisplayMember = "Key"
        Me.cmbDateRange.ValueMember = "Value"

     End Sub

    Sub MySub()

        Dim myArray(1000) As Account

        For i As Integer = 0 To 999

            myArray(i) = New Account(CStr(i))
        Next

    End Sub



End Class

Public Class Account
    Public _myString As String

    Public Sub New()
    End Sub

    Public Sub New(ByVal paramString As String)
        _myString = paramString
    End Sub

    Public Property MyString() As String
        Get
            Return _myString
        End Get
        Set(ByVal value As String)
            _myString = value
        End Set
    End Property


End Class

Start Free Trial
[+][-]06.06.2007 at 06:36AM PDT, ID: 19224994

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.06.2007 at 12:58PM PDT, ID: 19228124

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.06.2007 at 04:56PM PDT, ID: 19229432

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.06.2007 at 04:58PM PDT, ID: 19229444

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: .NET, Miscellaneous Programming
Tags: datagrid, display, array
Sign Up Now!
Solution Provided By: cheddar73
Participating Experts: 1
Solution Grade: A
 
 
[+][-]06.07.2007 at 07:00AM PDT, ID: 19233561

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.07.2007 at 11:00AM PDT, ID: 19235730

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32