Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

 

<%@ 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>

Go Beavs!!!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...