
June 20th, 2001, 07:32 AM
|
|
Contributing User
|
|
Join Date: Dec 2002
Posts: 14,578
  
Time spent in forums: < 1 sec
Reputation Power: 22
|
|
|
error on datareader
<i><b>Originally posted by : P.MUTHUKUMAR (pmkrajen@rediffmail.com)</b></i><br />hello guys pls help me to solve this error.I got this error when working with DATAREADER<br /><br />Object variable or With block variable not set <br />Description: An unhandled exception occurred at runtime during the execution of the current web request. Please review the stack trace below to get a better understanding of what the error is and where it originated from in the code. <br /><br />Exception Details: System.NullReferenceException: Object variable or With block variable not set<br /><br />Source Error: Line:13<br /><br /><br />Line 11: MyCommand=New SQlCommand(query,Connstr)<br />Line 12: MyCommand.ActiveConnection.Open()<br />Line 13: MyCommand.Execute(myReader)<br /><br />MY CODE:<br /><%@ Page Language="vb" Debug="true" %><br /><%@ Import Namespace="System.Data" %><br /><%@ Import Namespace="System.Data.SQL" %><br /><script runat="server"><br />Sub ListsAdd(Item as string)<br />ShipMethod.Items.add(Item)<br />end sub<br />Sub Page_Load(s As Object,e As EventArgs)<br />query="Select * from ShippingMethods"<br />Connstr="server=localhost;uid=sa;database=net"<br />MyCommand=New SQlCommand(query,Connstr)<br />MyCommand.ActiveConnection.Open()<br />MyCommand.Execute(myReader)<br />While myReader.Reader()<br />ShipMethod.Items.Add(myReader.Item)<br />end while<br />end sub<br /></script><br /><form runat="server"><br /><asp  ropDownList id="ShipMethod" runat="server" /><br /></form><br /> <br /> <br /><br />
|