I can't get the below code to work. It keeps giving me the error "Invalid attempt to read when no data is present."... Also, instead of MyReader.GetValue(0) how I do it so that I refer to the field names, such as MyReader.GetValue("Headline")?
<% @Import Namespace="System.Data" %>
<% @Import Namespace="System.Data.SqlClient" %>
<script language="VB" runat="server">
Public Sub Page_Load(sender as object,e as eventargs)
Dim myConnection as New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))
Dim strSQL as String = "select Headline, PubDate, Teaser, Author, CLB, CURLs, Active, BodyText from CSL_TBLNews where NewsID=" & request("id") & " order by PubDate asc"
Dim MyCommand As SqlCommand
Dim MyReader As SqlDataReader
Dim headlineString as String
MyCommand = New SqlCommand(strSQL, MyConnection)
MyReader = MyCommand.ExecuteReader
HeadlineString = MyReader.GetValue(0)