kcwallace Posted May 27, 2004 Posted May 27, 2004 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> Quote Go Beavs!!!
wessamzeidan Posted May 27, 2004 Posted May 27, 2004 try this reader.read() x=reader("e1").tostring() response.write(vbcr & x) Quote Proudly a Palestinian Microsoft ASP.NET MVP My Blog: wessamzeidan.net
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.