Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vb.net 2010 can't seem to fill grid?

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
I am using VB.NET 2010 Pro here at work and can't make this work which does work at home using vb.net 2010 Express.
it also works here at work in ASP.NET 2010 using the same IDE as above (pro).
it is unbound since I want to be able to add different data to it.
I also have a Storedprocedure in SQL getting the data, But there does not seem to be an option to select an SP in the Wizard? even though there is one in ASP.NET in its grid?
So what am I missing? the grid is just a gray square on my form with no columns, headings or no data.
Code:
   Public Sub PopulateGrid()
        Dim cnn As SqlConnection
        cnn = New SqlConnection(gblconnectionString)
        Try
            cnn.Open()
            Dim queryTrans As String
            queryTrans = "Select * from Transactions Order by PickupTime DESC;"
            Dim daTrans As New SqlDataAdapter
            Dim dtTrans As New DataTable
            daTrans.SelectCommand = New SqlCommand(queryTrans, cnn)
            daTrans.Fill(dtTrans)
            DataGridView2.DataSource = dtTrans

DougP
 
DOOH
if you specify the wrong GRID it will NOT work
Sorry my bad
DataGridView[highlight #FCE94F]2[/highlight].DataSource = dtTrans
should be
DataGridView[highlight #FCE94F]3[/highlight].DataSource = dtTrans

DougP
 

This is why I NEVER use default names for my controls, I ALWAYS name them to something meaningful to me. :)

Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top