Re: ProfileProvider : invalid connection
Posted by: Hubert CANEVET
Date: July 13, 2013 03:45AM

Oh well, I should swear I already tried that before posting ...

I eventually got it like that :

conn.Open();

MySqlCommand cmd =
new MySqlCommand("SELECT PKID FROM Users WHERE UserName = '" + username + "'", conn);

MySqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow);
reader.Read();
string strPkId = reader.GetString(0);
reader.Close();

But, I had to do it before opening the transaction.
With a transaction attached to the MySqlCommand, the reader.Read() returns false, and then reader.GetString(0) throughs an exception that tells this :

"Invalid attempt to access a field before calling Read()"

which is somewhat surprising.

Well, for the moment being, the topic is to get information that is already stored by the membership module, so there is no reason to do it in a transaction, so I am going on.

If someone gets an explanation about this, and perhaps a way to get the data inside the transaction, that will be welcome.
There is a forum that is specialized about transaction, I am going to ask the question there.

Options: ReplyQuote


Subject
Written By
Posted
Re: ProfileProvider : invalid connection
July 13, 2013 03:45AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.