Monday, February 20, 2012

Problem with DataSet or SQL query

I've faced the following problem while forming DataSet. I'd like to ask the following SQL query:

___

select Users.UserID,Users.FirstName,Users.LastName, Users.Email, data.Suffix, data.Unit,data.Telephone, data.IM,

data.Website
from
(select UserID,
max(case PropertyName when 'Suffix' then PropertyValue end)Suffix,
max(case PropertyName when 'Unit' then PropertyValue end)Unit,
max(case PropertyName when 'Telephone' then PropertyValue end)Telephone,
max(case PropertyName when 'IM' then PropertyValue end)IM,
max(case PropertyName when 'Website' then PropertyValue end)Website
from
(
SELECT UserProfile.UserID, UserProfile.PropertyValue, UserProfile.PropertyDefinitionID,

ProfilePropertyDefinition.PropertyName FROM UserProfile,ProfilePropertyDefinition
WHERE UserProfile.PropertyDefinitionID=ProfilePropertyDefinition.PropertyDefinitionID
)table2
group by UserID)
data
inner join Users on Users.UserID = data.UserID
WHERE data.Suffix = 'IT';

__

Nothing happens while fulfilling as well (i.e. if to set up Breakpoint and watch the DataSet condition - it will be empty there). If to change the request to let's say some standart - then DataSet downloading begins - it seems there's something wrong with the request

I'm checking...If to look with the holp of request master and press "perform", data is reflected in a normal way...But as soon as i press "Bild", emptiness is shown as usual

Please, prompt me what to do

Initial code in the file .aspx.cs:

----------

UserInfo ds =new UserInfo();

UserInfoTableAdapters.UserInformationTableAdapter da =new UserInfoTableAdapters.UserInformationTableAdapter();

da.Fill(ds.UserInformation);

Info.DataSource = ds.UserInformation;

Info.DataBind();

Hello Alag,

Did the query gave the correct result in the SQL Query Analyzer?

If you are using an xsd dataset definition, execute the menu option Preview Data ... to see the xsd dataset works fine.

Jeroen Molenaar.

|||

Result on SQL Query Analyzer is correct.

AND RESULT CORRECT IN "Execute Query" in DataSet Ouery Builder.. But if press "Bild"..((( no correct

|||

Bild sounds like buildSmile, but what error message is the compiler reporting when "bildung".

Jeroen Molenaar.

|||

No error. Just nothing displays on the screen .. And as you see that empty DataSet.

Sorry for the poor English. I am from Russia, and the school taught him poorly.

|||

I thought "bild" was German. But your English is much, much better than my Russian!

Are you indeed using an xsd dataset?

Jeroen Molenaar.

PS: Ja nie gavarjoe paroeskie.

|||

I am using "Add New Item" -> "DataSet"

PS. You russian is good)Smile

|||

In that case you are using an xsd dataset file.

When you open the UserInfo dataset and select the datatable UserInformation. Give a right click on the mouse and select the option: Preview data ... preview.

Does it give any result?

Jeroen Molenaar.

|||

Yes, the results show

|||

We are now moving to the asp page. Can you show more of the code you are using?

Jeroen Molenaar.

|||

Default.aspx.cs:

using System;

using System.Data;

using System.Configuration;

using System.Web;

using System.Web.Security;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.WebControls.WebParts;

using System.Web.UI.HtmlControls;

publicpartialclass_Default : System.Web.UI.Page

{

protectedvoid Page_Load(object sender,EventArgs e)

{

UserInfo ds =newUserInfo();UserInfoTableAdapters.UserInformationTableAdapter da =new UserInfoTableAdapters.UserInformationTableAdapter();

da.Fill(ds.UserInformation);

Info.DataSource = ds.UserInformation;

Info.DataBind();

}

}

|||

Default.aspx

<%@. Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body style="background-color:#F7F7F7">
<form id="form1" runat="server">
<div>

<asp:DataList ID="Info" runat="server">
<ItemTemplate>
<table width="700" border="0" cellpadding="0" cellspacing="2" style="font-family:Tahoma; background-color:white;">
<tr>
<td style="width:130; background-color:#F7F7F7;"><asp:Image ID="Image1" runat="server" ImageUrl='' /></td>
<td valign="top" style="background-color:#F7F7F7"><table width="100%" border="0" cellpadding="0" cellspacing="0" style="background-color:#F7F7F7">
<tr>
<td style=" font-size: 13px;padding-left: 12px;text-decoration:underline;color:#003366;font-weight:bold; height:30px; background:background.png" >
<asp:Label ID="Label7" runat="server"><%# DataBinder.Eval(Container.DataItem, "FirstName")%></asp:Label>
<asp:Label ID="Label8" runat="server"><%# DataBinder.Eval(Container.DataItem, "LastName")%></asp:Label>
</td>
</tr>
<tr>
<td style="height:4px;"></td>
</tr>
...

<tr>
<td style="height:4px;"></td>
</tr>
</table></td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</div>
</form>
</body>
</html>

|||

Looks fine to me. Final piece of code: markup language of the default.asp.

Jeroen Molenaar.

PS: Whoah, that was fast!

|||

I don't understand ((.. what I want? The code above is default.aspx

|||

When I was typing my reply, you already added the markup code from default.aspx. My question to add the code was too lateSmile

The problem is propably in the definition of your DataList control on the page, but I don't know exactly. The Data Access/SQL server forum is not a perfect place for this problem.

You better ask your question in another forum about ASP, for example the getting started forum.

Good luck!

Jeroen Molenaar.

No comments:

Post a Comment