Dear all,
I'd like to ask for your advice in the following problem:
I've developed a web app using sql 2005. Now that I've migrated the
files to the definitive server which is running sql 2000 I'm running
into a problem. The root application that I'm hooking into stores
(after successful login) a guid value in the ASP.NET
Page.User.Identity.Name variable. My application takes that value and
uses that as a parameter for a sql query to retrieve the user's data,
which works fine on my 2005 server but breaks on the 2000 server.
The error returned is 'no row at position 0' at the row where it says
'GetUserByGuid(guid)[0]'; manual checking (logging into the 2000
server from a 2005 management studio express) seems to work fine: i've
outputted the guid value and manually created the query it should
generate which in turn returns the correct (1) data row. Logon issues
seem to be excluded as changing the password in web.config results in
a different (could not log in) error message.
The only thing I can think of is that sql 2000 is somehow more fussy
when it comes to uniqueidentifier values than 2005 is. Can anybody
confirm this and/or does someone have a suggestion on how to fix this?
Code snippet:
Index.aspx:
protected void Page_Load(object sender, EventArgs e) {
// Set user name
if (!IsPostBack)
Username.Text = _user.FullName;
/* Username is a div-tag; replacing '_user.FullName' with
'User.Identity.Name' outputs a GUID value that is valid in the
database, so the value should be retrieved correctly */
}
private EllipsDossierDAL.ellipsUserRow _user {
get {
// Retrieve information through the stored GUID
string guid = User.Identity.Name;
EllipsDossierDAL.ellipsUserRow user = new
UsersBLL().GetUserByGuid(guid)[0];
_userid = user.ID; // remember ID
return user;
}
}
UsersBLL.cs:
[DataObjectMethodAttribute(DataObjectMethodType.Select,
false)]
public EllipsDossierDAL.ellipsUserDataTable
GetUserByGuid(string guid) {
return Adapter.GetUserByGuid(new Guid(guid));
}
EllipsDossierDAL.xsd:
<DbSource ConnectionRef="EllipsConnectionString
(Web.config)" DbObjectName="ellips.dbo.ellipsUser"
DbObjectType="Table" FillMethodModifier="Public"
FillMethodName="FillByGuid" GenerateMethods="Both"
GenerateShortCommands="True" GeneratorGetMethodName="GetUserByGuid"
GeneratorSourceName="FillByGuid" GetMethodModifier="Public"
GetMethodName="GetUserByGuid" QueryType="Rowset"
ScalarCallRetval="System.Object, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
UseOptimisticConcurrency="True" UserGetMethodName="GetUserByGuid"
UserSourceName="FillByGuid">
<SelectCommand>
<DbCommand CommandType="Text" ModifiedByUser="True">
<CommandText>SELECT ID, firstname, middlename,
lastname, login, password, RoleID, email, AgreementIsSigned, guest,
IsNull(firstname, '') + ' ' + IsNull(middlename, '') + ' ' +
IsNull(lastname, '') AS FullName
FROM ellipsUser
LEFT JOIN EllipsUserSession ON ellipsUser.ID =
EllipsUserSession.fkUser
WHERE EllipsUserSession.[GUID] = @[EMAIL PROTECTED]
BY lastname, firstname, ID</CommandText>
<Parameters>
<Parameter AllowDbNull="False"
AutogeneratedName="GUID" ColumnName="GUID"
DataSourceName="ellips.dbo.EllipsUserSession"
DataTypeServer="uniqueidentifier" DbType="Guid" Direction="Input"
ParameterName="@[EMAIL PROTECTED]
" Precision="0" ProviderType="UniqueIdentifier"
Scale="0" Size="16" SourceColumn="GUID"
SourceColumnNullMapping="False" SourceVersion="Current">
</Parameter>
</Parameters>
</DbCommand>
</SelectCommand>
</DbSource>


|