Ok, here's the problem. This is the first time I'm trying to use a datagridview in just straight VB.NET. I'm trying to bind it to a datareader but nothing gets displayed. I checked the reader to see if it had information in it and it does. So why isn't the datagrid showing anything?
Everything that I have looked up uses a dataset. I don't want to use a dataset. All I want to happen is when I do a simple select, the results get displayed in the datagridview. Do I have to create columns because I thought the datagridview would do that when it gets bound?[/SIZE]
VB.NET:
[SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] strSql [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#800000]""[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] sqlConnect [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] SqlConnection
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] sqlReader [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] SqlDataReader[/SIZE]
[SIZE=2]
[/SIZE][/COLOR][/SIZE][SIZE=2]strSql = wfnSearch()
[/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][SIZE=2] strSql.Length <= 0 [/SIZE][SIZE=2][COLOR=#0000ff]Then
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Exit[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]
[/COLOR][/SIZE][SIZE=2]strSql = [/SIZE][SIZE=2][COLOR=#800000]"Select rtrim(FirstName) + ' ' + rtrim(LastName) "[/COLOR][/SIZE][SIZE=2] _
& [/SIZE][SIZE=2][COLOR=#800000]"From Contact_Info "[/COLOR][/SIZE][SIZE=2] _
& [/SIZE][SIZE=2][COLOR=#800000]"Where "[/COLOR][/SIZE][SIZE=2] & strSql[/SIZE]
[SIZE=2]
sqlConnect = [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] SqlConnection()[/SIZE]
[SIZE=2]
sqlConnect.ConnectionString = [/SIZE][SIZE=2][COLOR=#800000]"Server=myServer;Database=myDatabase;Trusted_Connection=True;"[/COLOR][/SIZE]
[SIZE=2][COLOR=#800000]
[/COLOR][/SIZE][SIZE=2]sqlConnect.Open()
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] sqlComm [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] SqlCommand(strSql, sqlConnect)[/SIZE]
[SIZE=2]
sqlReader = sqlComm.ExecuteReader
[/SIZE][SIZE=2]
dgResults.DataSource = sqlReader
Everything that I have looked up uses a dataset. I don't want to use a dataset. All I want to happen is when I do a simple select, the results get displayed in the datagridview. Do I have to create columns because I thought the datagridview would do that when it gets bound?[/SIZE]