Why won't this work

kcwallace

Centurion
Joined
May 27, 2004
Messages
175
Location
Austin, TX
Please do not laugh.

I want to read a result from a database and report the resilts to a aspx page. I stole the following from help files, but it does not work. can someone point tme in the right direction. i.m about ready to kick this ADO.net stuff to the curb.

Code:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="WebApplication1.WebForm1"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
	<HEAD>
		<title>WebForm1</title>
		<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
		<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
		<meta name="vs_defaultClientScript" content="JavaScript">
		<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
	</HEAD>
	<body MS_POSITIONING="GridLayout">
		<form id="Form1" method="post" runat="server">
		<%response.write(now)
		Dim connSql As new SqlConnection("server=PROCESS;database=DosimetrySQLDatabases;UID=sa;PWD=sa;")
        Dim queryCommand As SqlClient.SqlCommand
		queryCommand = New SqlClient.SqlCommand
		queryCommand.CommandType = CommandType.Text
		queryCommand.CommandText = "SELECT count([id]) as e1 FROM ProcedureMain"
		queryCommand.Connection = connSql

		connSql.Open()
        
		Dim reader As SqlClient.SqlDataReader
		reader = queryCommand.ExecuteReader()
		dim x 
		
		x=reader("e1").tostring()'<----Errors here "Invalid attempt to read when no data is present. "
		response.write(vbcr & x)
		
		

		%>
		</form>
	</body>
</HTML>
 
Back
Top