Why am I getting this message I checked the sql behind it and it is returning one row and there is a value in the first column so it should work with no problem.
SqlConnection sqlConnection1 = new SqlConnection("Data Source=.\\SQLEXPRESS;Attac
hDbFilenam
e=|DataDir
ectory|\\A
SPNETDB.md
f;Integrat
ed Security=True;User Instance=True");
SqlCommand cmd = new SqlCommand();
MembershipUser myObject = Membership.GetUser();
string userIDD = myObject.ProviderUserKey.T
oString();
cmd.CommandText = "GetCustInfo";
cmd.CommandType = CommandType.StoredProcedur
e;
cmd.Connection = sqlConnection1;
cmd.Parameters.AddWithValu
e("@userID
", userIDD);
sqlConnection1.Open();
SqlDataReader DReader = cmd.ExecuteReader();
profile_ID = Convert.ToInt32(DReader.Ge
tValue(0))
;
The error I am getting is "Invalid Attempt to read when no data is present" and it is on
profile_ID = Convert.ToInt32(DReader.Ge
tValue(0))
;
Here is the extended error
System.InvalidOperationExc
eption was unhandled by user code
Message="Invalid attempt to read when no data is present."
Source="System.Data"
StackTrace:
at System.Data.SqlClient.SqlD
ataReader.
GetValue(I
nt32 i)
at GetCustomerProfile.GetCust
Profile(St
ring UserID) in c:\Documents and Settings\Scott\My Documents\Visual Studio 2005\WebSites\AjaxSigns2\A
pp_Code\Ge
tCustomerP
rofile.cs:
line 157
at GetCustomerProfile..ctor(S
tring UserID) in c:\Documents and Settings\Scott\My Documents\Visual Studio 2005\WebSites\AjaxSigns2\A
pp_Code\Ge
tCustomerP
rofile.cs:
line 26
at storeCheckout.Wizard1_Fini
shButtonCl
ick1(Objec
t sender, WizardNavigationEventArgs e) in c:\Documents and Settings\Scott\My Documents\Visual Studio 2005\WebSites\AjaxSigns2\s
toreChecko
ut.aspx.cs
:line 151
at System.Web.UI.WebControls.
Wizard.OnF
inishButto
nClick(Wiz
ardNavigat
ionEventAr
gs e)
at System.Web.UI.WebControls.
Wizard.OnB
ubbleEvent
(Object source, EventArgs e)
at System.Web.UI.WebControls.
Wizard.Wiz
ardChildTa
ble.OnBubb
leEvent(Ob
ject source, EventArgs args)
at System.Web.UI.Control.Rais
eBubbleEve
nt(Object source, EventArgs args)
at System.Web.UI.WebControls.
Button.OnC
ommand(Com
mandEventA
rgs e)
at System.Web.UI.WebControls.
Button.Rai
sePostBack
Event(Stri
ng eventArgument)
at System.Web.UI.WebControls.
Button.Sys
tem.Web.UI
.IPostBack
EventHandl
er.RaisePo
stBackEven
t(String eventArgument)
at System.Web.UI.Page.RaisePo
stBackEven
t(IPostBac
kEventHand
ler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePo
stBackEven
t(NameValu
eCollectio
n postData)
at System.Web.UI.Page.Process
RequestMai
n(Boolean includeStagesBeforeAsyncPo
int, Boolean includeStagesAfterAsyncPoi
nt)