SQL Server :: How To Avoid Using Subqueries
Dec 23, 2010How can I avoid using subqueries and still be able to select the same results in a query like this;
[Code]....
How can I avoid using subqueries and still be able to select the same results in a query like this;
[Code]....
Actually i have created three tables -IMAGE[IMAGE_ID,IMAGE],REQUEST[REQUEST_ID,STATUS,REASON] and PROFILE where primary keys are IMAGE_ID ,REQUEST_ID and USERNAME respectively and USERNAME is present in IMAGE and REQUEST tables as foreign key......
i want to select image_id from table IMAGE where USERNAME='uName'[passed through querystring] and REASON='uploading is done' and i want to populate the data in dropdownlist but i dont know how to do that using sub queries...
When i am executing following query:
INSERT INTO Customer (ID, FullName, WebSite, AnnualFee,
[code]...
I get the Subqueries are not allowed in this context. Only scalar expressions are allowed - i am going to run into this quite alot so I figuredI'd better see what the right way is!
as i am new to ASP.NETi have a database for employee appraisal for a company. in that table
employeeid,
appraisalid(primary key),
objective,
[code]...
i get the above error when i try to run this sql statement
INSERT INTO PSPS_Posts (Post, Date_Posted, user_ID, Thread_ID) VALUES (@Post, @Date_Posted, @user_ID, (SELECT Thread_ID FROM PSPS_Thread WHERE Thread_ID = (SELECT MAX(Thread_ID) FROM PSPS_Thread
I created an asp.net Server control that derives from a LinkButton, and renders a small javascript function to the page. I want to use this control many times on the page, but just want the javascript to be rendered once on the page. On the other hand, I rather not manually add it in a js file, because i don't want to have a chance of forgetting to add the js file in the future.
View 3 RepliesAdding runat="server" is not rendering my server tags <%...%>
I have a masterpage with a few <li> for menu and since I have to set class=selected for the current page, I am using a little server tag to find the url and assign the particular class.
I have total of 10 <li> and not all menu is available to all types of user, I need to toggle few of the <li> if the user is not admin, so I have runat="server" added to them so I can set their visible=false through c#
Here is how it is at a glance:
<li runat="server" id="liBlog" class='<%= Request.Url.AbsoluteUri.EndsWith("/Blog") ? "selected" : "" %>'><a href="/Blog">Group Blog</a></li>
<li runat="server" id="liPoll" class='<%= Request.Url.AbsoluteUri.EndsWith("/Poll") ? "selected" : "" %>'><a href="/Poll">Poll</a></li>
<li id="liInvite" class='<%= Request.Url.AbsoluteUri.EndsWith("/Invite") ? "selected" : "" %>'><a href="/Invite">Invite</a></li>
<li id="liFavourite" class='<%= Request.Url.AbsoluteUri.Contains("/Favourite") ? "selected" : "" %>'><a href="/Favourite">My Favourites</a></li>
The <li> without runat="server" works fine, when on correct page the source code shows class="selected" or class="" as appropriate, the other <li> used to work fine too, until I decided to add the runat="server".
Once I added that runat="server", the whole block of class="" is being sent out to the html page, its not processing the server tags at all! I right click on the html and look at the source, it's being rendered as:
<li id="ctl00_ctl00_ContentPlaceHolder1_liBlog" class="<%= Request.Url.AbsoluteUri.EndsWith("/Blog") ? "selected" : "" %>"><a href="/Blog">Group Blog</a></li>
It's pouring out my server tags into the source code!
Why is this behaviour seen? How can I avoid it?
(I have tested this with a vanilla asp.net site running from the webdev server and it is a problem here also):
I have the following markup in my .master file
[code]....
Clearly Asp.Net does something to encode the url. As it happens, I really need the head tag to be runat="server" and I would also like to be able to have "&" in link-urls within it is there some trick I can use to have my cake and eat it too?
I recently noticed that I had a big hole in my application because I had done something like:
<input type="text" value="<%= value%>" />
I know that I should have used Html.Encode, but is there any way to do that for all values, without having to do it explicitly?
i need a information of how to avoid the reload source editor window for after xml file save using Asp.net
View 1 Repliesim using sql server 2008
as per microsoft, [URL]
when i execute the following
set identity_insert on
//insert statements here
set identity_insert off
the identity of the column is set to the maximum value. can i aviod this.
consider the following scenario,
my table has 2 rows as follows
id, name comm
1, John, 232.43
2, Alex, 353.52
now using the above code, when i insert
10, Smith, 334.23
as per the above link, sql server automatically sets the identity to 10. so for newly inserted records(without using identity_insert on), id automatically starts with 11.
i want the identity value to be 3, after using identity_insert on/off
I'm developing ASP.NET applications and stuck with a "problem" relating to resubmit behaviour. I'm controling the re-submit using a counter in form submit event which disables the submit if it's already been posted. My application is a 3 step workflow and when the 3rd step is shown the transaction was submited from step2 to step 3. What's my problem? Well... i want to avoid the user to resubmit the data by pressing the F5 or all other possibility. I don't want to disable the key because may be workarounds. I'm wondering if i can remove the post data in a HTTP module that runs after the render was completed and right before the response is sent to the user.
View 2 RepliesI'm have a page which I sent a parameter through the query string.
If I'm retrieving it with Request.QueryString["Format"] I'm having troubles with the type 'CDDVD'. It's being returned as 'CD\DVD'. It's important I get this as the right string.
How do I avoid the extra backslash? Or even get rid of it later?
I have used the database data to combo box values. But the problem is i don't now how to avoid the duplicate data. for e.g In a single column name called "department " is used so many time but i wanted it only one time should be displayed the combo box.
View 5 Repliesi want to avoid duplicate entries from array.....(in c#)
View 2 RepliesI'm working on a website powered by .NET asp/C# code. The clients require that sessions have a 25 minute timeout. However, sometimes the site is used, and a user stays connected for long periods of time (longer than 25 mins). Session_End is triggered:
protected void Session_End(Object sender, EventArgs e)
{
Hashtable trackingInformaiton = (Hashtable)Application["trackingInformation"];
trackingInformaiton.Remove(Session["trackingID"]);
}
The user returns some time later, but when they interact with the website, they get an error, and we get this email notification:
User: Unauthenticated User
Error: System.Web.HttpException
Description: Failed to load viewstate. The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request...
The telling part of the stack trace is System.Web.UI.Control.AddedControl. Apparently, the server has thrown away the session data, and is sending new data, but the client is trying to deal with old data. Hence the error that "the control tree into which viewstate is being loaded [doesn't] match the control tree that was used to save the viewstate during the prevoius request."
So here's the question. How can I force instruct the user's browser to redirect to a "you're logged out" screen when the connection times out? (Is it something I should add to the Session_End method?)
protected void Button3_Click(object sender, EventArgs e) //export
{
GridView2.AllowPaging = false;
GridViewExportUtil.Export("Сводка.xls", this.GridView2);
GridView2.AllowPaging = true;
}
I need to avoid pageing for XLS export :-/
I am using .net 3.5 framework and i am using repeater control in my application.I am using link button to display the records.Displaying 9 records in a page.Show all button is there.When i click on show all button(Result of 250 records) then the page is loading and hanging for some time anf then it is displaying the all records.I know the time taken between the server and the browser.But i need to avoid the hanging of the page and the loading time should be reduced.How to solve this issue.If the page contains 9 products then it is loaded quickly.But if it contains lot of images then it's hanged. some of my friends told to use the jquery but i have noo idea regarding jquery so can anyone give an solution for this.Till it's breaking my head.
View 2 RepliesI have a webform which users fill in and all fields are submitted to table. How do I check that the record doesn't already exist in the table before the data is submitted? And if the data does exist I'd like to display error message label.
View 10 RepliesI know this is a very common problem and a quick search in google offers a lot of solutions. However I could only find one person that came across it in the same way I am and no-one answered their question.
The scenario which causes this is if the page has been left dormant for a period of time and then a button is pressed which runs some sort of command. This might be pressing the logout button or trying to submit a contact form after having walked away at some point and then returning and hitting Send.
I do not have posts or actions in my form, it looks like this: <form id="form1" runat="server">
I have also added the following line to my web.config: <pages enableEventValidation="false" iewStateEncryptionMode="Never">
Is that possible to write namespace into some other file commonly.which should be automatically includes my page. namespace like:using System;
View 1 RepliesI have 5 dropdpwnlist in asp.net page.. the 5th dropdwpnlist will show data based on 4th dropdownlist. and 4th dropdwpnlist will show data based on 3rd dropdownlist. and 3rd dropdwpnlist will show data based on 2nd dropdownlist. and 2th dropdwpnlist will show data based on 1st dropdownlist... All dropdownlist has auto postback=true.. so it cause postaback each time.. i want to avoid postback coz it refresh all page again and again and shows data.. coz my aplication is in hosting server..
View 5 Replieswhat should i write in web config file in asp.net so that my session time is extended. the exact location where should i place the code in web config
View 6 RepliesIm getting some images from a webpage at a specified url, i want to get their heights and widths. I'm using something like this:
Stream str = null;
HttpWebRequest wReq = (HttpWebRequest)WebRequest.Create(ImageUrl);
HttpWebResponse wRes = (HttpWebResponse)(wReq).GetResponse();
str = wRes.GetResponseStream();
var imageOrig = System.Drawing.Image.FromStream(str);
int height = imageOrig.Height;
int width = imageOrig.Width;
My main concern with this is that that the image file may actually be very large,Is there anything I can do? ie specify to only get images if they are less than 1mb?or is there a better alternative approach to getting the dimension of an image from a webpage?