I'm using asp.net based on VB.Net,
I want to access my Database and get the data, then I want to make list using that data.
An ASP GridView's style is not I want, so I decide to use another method.
So this is my code:
Dataget.vb
Public Shared Function GetData() As DataSet
Dim con As New OleDb.OleDbConnection
Dim dbProvider As String
Dim dbsource As String
Dim ds As New DataSet
Dim da As OleDb.OleDbDataAdapter
Dim query As String
dbProvider = "PROVIDER=SQLOLEDB;"
dbsource = "Data Source = ""
con.ConnectionString = dbProvider & "Server="
con.Open()
query = "SELECT * FROM Table1"
da = New OleDb.OleDbDataAdapter(query, con)
da.Fill(ds, "Table1")
con.Close()
Return ds
End Function
**
And this is my ASP.Net page code.
**
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Master.Master" CodeBehind="List.aspx.vb" Inherits="WebApplication3.List1" %>
<%@ Import Namespace="WebApplication3" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<div>
</div>
<form class="selection">
<ul class="list">
<%
Dim ds As New Data.DataSet
ds = DataGet.GetData()
Dim title As String
Dim counts As Integer = ds.Tables("Table1").Rows.Count - 1
For i = 0 To counts
title = ds.Tables("Table1").Rows(i).Item("title")
Response.Write("<li a href='" & title & "'>" & title & "</a></li>")
Next
%>
</ul>
</form>
</asp:Content>
I am retrieving the Data successfully, but I think this is a inefficient way to get the data.
So, my question is this.
I need a more efficient way, can you guys give me any advice?