try
{
SqlConnection sqlConnection1 = new SqlConnection("Data Source=.\\SQLEXPRESS;Attac
SqlCommand cmd = new SqlCommand();
MembershipUser myObject = Membership.GetUser();
string userIDD = myObject.ProviderUserKey.T
cmd.CommandText = "GetCustInfo";
cmd.CommandType = CommandType.StoredProcedur
cmd.Connection = sqlConnection1;
cmd.Parameters.AddWithValu
sqlConnection1.Open();
SqlDataReader DReader = cmd.ExecuteReader();
while (DReader .Read())
{
profile_ID = DReader[0];
}
}
finally
{
// close the reader
if (DReader != null)
{
DReader .Close();
}
// Close the connection
if (sqlConnection1 != null)
{
sqlConnection1 .Close();
}
}
Main Topics
Browse All Topics





by: JimBrandleyPosted on 2007-08-29 at 23:05:27ID: 19797765
You need to switch it to something like this:
while (DReader.Read())
{
index = 0;
while (index < colCount)
{
something= DReader[index];
// OR
something = DReader.GetValue(0);
index++;
}
}
DReader.Close();
DReader.Dispose();
// and CloseConnection();
Jim