I am querying the database to fill the Datagrid. I dont want everything in the database to be displayed on the table just some important information.
I am new to VB.net I am used to asp.net core MVC and entity frameworkork
Data source is an invalid type. It must be either an IListSource, IEnumerable, or IDataSource. Here is my code below
Private Sub GetTSANotification()
Dim query As String = "SELECT * FROM [dbo].[notifyMe]"
Dim DBConnection As String = System.Configuration.ConfigurationManager.ConnectionStrings("Notification").ConnectionString
Using cmd As New SqlConnection(DBConnection)
Using da As New SqlCommand(query)
Using sda As New SqlDataAdapter()
da.Connection = cmd
sda.SelectCommand = da
Using data As New DataTable()
sda.Fill(data)
notifyReport.DataSource = da
notifyReport.DataBind()
End Using
End Using
End Using
End Using
End Sub
Here is my Datagrid. I just want to display like 5 item from the DB, others in the DB column are not necessary for the user
<asp:GridView CssClass="table table-bordered table-striped" ID="notifyReport" runat="server" AutoGenerateColumns="false" AllowPaging="true" OnPageIndexChanging="OnPageIndexChanging" PageSize="10">
<Columns>
<asp:BoundField DataField="id" HeaderText="Id" SortExpression="id"></asp:BoundField>
<asp:BoundField DataField="customerName" HeaderText="Customer Name" SortExpression="customerName"></asp:BoundField>
<asp:BoundField DataField="customerEmail" HeaderText="Email" SortExpression="customerEmail"></asp:BoundField>
<asp:BoundField DataField="fee" HeaderText="Fee" SortExpression="fee"></asp:BoundField>
<asp:BoundField DataField="feedType" HeaderText="Feed Type" ReadOnly="True" SortExpression="feedType"></asp:BoundField>
<asp:BoundField DataField="narrationDesc" HeaderText="Narration" ReadOnly="True" SortExpression="narrationDesc"></asp:BoundField>
</Columns>
</asp:GridView>
"SELECT * FROM [dbo].[notifyMe]"
-->"SELECT *col1, col2, ... FROM [dbo].[notifyMe]"