how to retrive values from database into a table using vb.net??????
I tried but i don't have either output??????
How to do this???
and my code is:

<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
<% @Import Namespace="System.Data" %>
<% @Import Namespace="System.Data.SqlClient" %>
<script runat="server">
sub Page_Load()
       Dim con As New SqlConnection
Dim cmd As New SqlCommand

 con.ConnectionString = "Data Source=IMMANUEL-PC\SQLEXPRESS; Initial Catalog=dbkarthi; UID=test; PWD=test1;" 
 con.Open()
 cmd.Connection = con
 cmd.CommandText = "select * from det"
 Dim lrd As SqlDataReader = cmd.ExecuteReader()
End sub         

</script>
<form runat="server">
<asp:Repeater id="customers" runat="server">

<HeaderTemplate>
<table border="1" width="100%">
<tr bgcolor="#b0c4de">
<th>ID</th>
<th>Name</th>
<th>Address</th>
<th>Age</th>
<th>Gender</th>
</tr>
</HeaderTemplate>

<ItemTemplate>
<tr bgcolor="#f0f0f0">
<td><%#DataBinder.Eval(Container.DataItem, "id")%> </td>
<td><%#DataBinder.Eval(Container.DataItem, "name")%> </td>
<td><%#DataBinder.Eval(Container.DataItem, "address")%> </td>
<td><%#DataBinder.Eval(Container.DataItem, "age")%> </td>
<td><%#DataBinder.Eval(Container.DataItem, "gender")%> </td>

</tr>
</ItemTemplate>

<FooterTemplate>
</table>
</FooterTemplate>

</asp:Repeater>
</form>
</body>
</html>

I love this free tutorial PDF. It contains a chapter on how to use SQL databaases. I have no clue why you are doing all that HTML stuff.

i just want to display the output in the table thats why i created a table using html...

is it going to be displayed on a browser? If not then just use VB.NET's built-in grid control. In any event. read the chapter about databases in that tutorial

yes it is going to be displayed in browser

I got the output and the corrected code is:

<% @Import Namespace="System.Data" %>
<% @Import Namespace="System.Data.SqlClient" %>
<script runat="server">
sub Page_Load()
       Dim con As New SqlConnection
Dim cmd As New SqlCommand

 con.ConnectionString = ///my connection string///
 con.Open()
 cmd.Connection = con
 cmd.CommandText = "select * from det"
 customers.DataSource = cmd.ExecuteReader() 
 customers.DataBind()
End sub         

</script>
<form runat="server">
<asp:Repeater id="customers" runat="server">

<HeaderTemplate>
<table border="1" width="100%">
<tr bgcolor="#b0c4de">
<th>ID</th>
<th>Name</th>
<th>Address</th>
<th>Age</th>
<th>Gender</th>
</tr>
</HeaderTemplate>

<ItemTemplate>
<tr bgcolor="#f0f0f0">
<td><%#DataBinder.Eval(Container.DataItem, "id")%> </td>
<td><%#DataBinder.Eval(Container.DataItem, "name")%> </td>
<td><%#DataBinder.Eval(Container.DataItem, "address")%> </td>
<td><%#DataBinder.Eval(Container.DataItem, "age")%> </td>
<td><%#DataBinder.Eval(Container.DataItem, "gender")%> </td>

</tr>
</ItemTemplate>

<FooterTemplate>
</table>
</FooterTemplate>

</asp:Repeater>
</form>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.