|
-
Jun 28th, 2005, 03:38 AM
#1
Thread Starter
Junior Member
My datagrid didn't show data,why?please see my code.
I use asp.net and sql server 2000
Problems are:
I debug my web page but datagrid control didn't show any data from my database. and if i would like to create add, delete update and search button for datagrid, please give me a advices or show me...
Thanks
<%@ import Namespace="System.Data.SqlClient" %>
<%@ import Namespace="System.Data" %>
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="Mypage.aspx.vb" Inherits="Myproject.Mypage" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Mypage</title>
<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
'declarations
Dim conLath As SqlConnection
Dim cmdLath As SqlCommand
Dim rdrLath As SqlDataReader
conLath = New SqlConnection( _
"server=local;uid=;pwd=; " & _
"database=MySQLDB")
conLath.Open
cmdLath = New SqlCommand ( _
"select field1,field2 from MyTable", _
conLath)
rdrLath = cmdLath.ExecuteReader
gridLath.DataSource = rdrLath
gridLath.DataBind
rdrLath.Close
cmdLath.Dispose
conLath.Close
End Sub
</script>
<html>
<head>
<title>Test</title>
</head>
<asp ataGrid id="gridLath" runat="server"></asp ataGrid>
</body>
</html>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|