Hope someone can help me out of this issue.
Im trying to get data from a mdf database into a repeater.
I have created the dbml file, its called “Thedatabaseconnection.dbml”, i have the web.config file and in that i have a connectionstring called “masterDBConnectionString”.
I have this vb class file.
Imports Microsoft.VisualBasic
Imports System.Web
Public Class connectionDBtesttable
Private _testId As Integer
Private _testCat As String
Private _testInfo As String
Private _testNumbers As Integer
Private _testDate As Date
Public Property test_id() As Integer
Get
Return _testId
End Get
Set(value As Integer)
_testId = value
End Set
End Property
Public Property test_cat() As String
Get
Return _testCat
End Get
Set(value As String)
_testCat = value
End Set
End Property
Public Property test_info() As String
Get
Return _testInfo
End Get
Set(value As String)
_testInfo = value
End Set
End Property
Public Property test_numbers() As Integer
Get
Return _testNumbers
End Get
Set(value As Integer)
_testNumbers = value
End Set
End Property
Public Property test_datetime() As Date
Get
Return _testDate
End Get
Set(value As Date)
_testDate = value
End Set
End Property
End Class
I have this code_behind
Imports System
Imports System.Linq
Partial Class _default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
Call linqdb()
End If
End Sub
Private Sub linqdb()
Using datacontext As New ThedatabaseconnectionDataContext()
Dim query = From a In datacontext.GetTable(Of testtable)() _
Order By a.test_id Descending _
Select a
Repeater1.DataSource = query.ToList
Repeater1.DataBind()
End Using
End Sub
End Class
I have this main page
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="default.aspx.vb" Inherits="_default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Repeater ID="Repeater1" runat="server">
</asp:Repeater>
</div>
</form>
</body>
</html>
But i cant get the data from the DB into the repeater1…
Can someone plz help me, this is my first LinQ connection.
You have not specified what markup should be rendered for each item in the repeater. As an example try altering your markup as follows:
This will simply render info and date for each item returned from the DB. You can specify more complicated markup if you want to. For more info on this topic you can check out the MSDN page about the Repeater control.