SQL Server :: Subqueries Are Not Allowed In This Context?
Dec 6, 2010When i am executing following query:
INSERT INTO Customer (ID, FullName, WebSite, AnnualFee,
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!
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
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...
How can I avoid using subqueries and still be able to select the same results in a query like this;
[Code]....
Here are my codes:
[Code]....
And here's the error I got:
Implicit conversion from data type sql_variant to varbinary is not allowed. Use the CONVERT function to run this query.
Description:
An unhandled exception occurred during the execution of the current web request. review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: Implicit conversion from data type sql_variant to varbinary is not allowed. Use the CONVERT function to run this query.
Page1 contains GridView1 which displays info from Table1.GridView1 contains a CommandButton which, when clicked inserts the values of all columns, plus a calculated value which goes into an extra column into Table2 handled in the RowCommand event handler of GridView1.Page2 contains GridView2 which displays info from Table2.GridView2 allows the user to alter the value of one of the columns in Table2 using the standard Edit/Update link.All this worked well until...I added UserId and SessionId fields to Table2 (uniqueidentifier and varchar(MAX) respectively,I added the following code to Page1 Code Behind to insert these values from the RowCommand handler:
[Code]....
All of this works beautifully. But... I then added this code to GridView2's RowUpdating event handler:
[Code]....
My filter Expression was working fine with filtering by Control Parameters.When I added the Phone Parameter it went nuts - with the Phone Parameter the GridView just Comes out blank upon loading the page (without it would show Select * from Individuals)Is it because the phone field is populated with numbers? Don't get it.... In the SQL server the 'phone' field is set to 'varchar(30)' and nulls are allowed.here is my code:
[Code]....
i'm parsing a few .net resource files (.resx).In that, i have this piece of data:informaciónThis works in my .net app, but when i try to load this file in my xml document
XDocument xmlDoc = XDocument.Parse(s);
i get this error:Reference to undeclared entity 'oacute'.
I'm using the HttpRunTime.Cache.Add to create a routine that runs every 5 mins to post data out of my app to the main DB, and this works fine. However I also need to import some files from disk in this routine. I have my document directory set up in my web.config as a ~/ relative path and resolve this in normal controller actions using Server.MapPath(string). How can I do this in my Global.asax.cs code -when I try to access it, it throws an error?
View 3 RepliesI have a problem when I add the following line at the beginning of my Global.asax.vb
[Code]....
I get a "Server process is not available in this context" error. (System.Web.HttpServerUtility.MapPath(String path) +8660257)
I need the physical path to the Database1.mdb file because I open a Database connection in the Session_Start sub.
using System.Data.SqlClient;
using System.Data;
public static SqlDataReader GetCategories()
{
SqlDataReader reader;
string sql = "SELECT * FROM CATEGORIES";
using (SqlCommand command = new SqlCommand(sql, ConnectionManager.GetConnection())); //possible //mistaken empty statement
{
reader = command.ExecuteReader(CommandBehavior.SingleResult | CommandBehavior.CloseConnection);
}
}
I am getting a couple of errors in this code that I can't figure out. One is regarding the empty statment next to the comments above and the other one is regarding reader=command, it says command does not exist in the current context.
Let's say a control X has a template called RowTemplate.
So X's markup would be like:
<foo:X>
<RowTemplate>
<foo:Y>...</foo:Y>
</RowTemplate>
</foo:X>
My question is: How can the Y control be sensitive to the data context? I know I can use template inline tags to get access to the data context: <%# Eval("Id") %>, but I cannot pass this information to Y because template inline tags are not allowed in server controls.
So I don't know how I could use the Object's Id (Eval("Id")) in Y.
I'm using a custom ashx handler to handle a file upload. When run locally, the file uploads fine.When I use the same setup on the web server I get a "Index out of range" error.In firebug I see the binary contents of the file in the post data and the file name is also passed in the query string.Any one seen this before?I`m sure its something minor, but its driving me up the wall.
Request header:
Key Value
Request POST /Secured/UploadHandler.ashx? HTTP/1.1
Accept text/html, application/xhtml+xml, */*
Referer http://cms.webstreet.co.il/Secured/fileUpload.aspx
Accept-Language he-IL
User-Agent Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
Content-Type multipart/form-data; boundary=---------------------------7db13b13d1b12
Accept-Encoding gzip, deflate
[code]...
I'm using an .ashx handler to retrieve an image file... It queries a local database, which retrieves the URL of an image which is hosted on Amazon S3.
But I can't use context.response.write(AmazonS3URL) because it returns the error '...is not a virtual path'.
Can context.response.write only return files that are on the local machine? Or is there another function to call remote files?
Right off the bat, I hit a wall with the default test added by VS 2010. I forget the exact error now, but it was saying that the tests weren't executed... something about the server. Before I sounds too stupid, the "fix" was to remove the web attributes on the test, causing my tests to NOT need to run through the web server. At this point I have a number of simple, but relevant controller tests up and running.
QUESTION #1.Is it commonplace to run unit tests throught the web server. I have a hard time envisioning that taking place on the build server once I port this solution. It feels much quicker and cleaner to run them directly against the code.
QUESTION #2.I have a security helper class that simply checks to see if the authenticated user is a member of the required Active Directory group before allowing them to perform updates in the application.
I wanted to test it, but the helper uses the HttpContext.Current instance.Should I require this test to run through the web server, or should I change it to accept the context as an argument and mock that context for the unit test? I've installed MOQ, but haven't started the learning process with it yet.
Here is the helper class:
[Code]....
I have written simple HttpModule. context.Response.Output.Write is working fine. but not context.Response.Write().
View 2 Repliesi am trying to retrieve data from sql database but I get this error: < An expression of non-boolean type specified in a context where a condition is expected, near ')'. > whats this error meaning?
View 10 RepliesMy Question is can we extend one context to another in Entity Framework 4. Following is the problem background.
I am using EF4 for developing a Web-Application. My Web Application has 3 projects.
One project is for storing candidate CV information.
Another project is for storing customer information.
Final project is called CORE. this CORE contains a edmx file that should be extended by CV and CRM.
As an example email address table can be shared by both customer (CRM) and CV. To share one table with another, we should be able to extend one context (CV context) with other context (customer context). Could some one having experience using Entity Framework share your experience with me to find whether this is possible.
We have 3 edmx files in three class libraries:
Person class library(Core) with core.edmx-Basic details related to a person(name, email) CV Class library with CV.edmx wich have CV related data(Experiance,skills) Customer Relationship management system(CRM) which have customer data(sales data...)
Then we want to use core class library edmx file(Core.edmx) with cv.edmx (basically cv tables should be able to use tables from core tables) . Same way we want to use the core.edmx with CRM.edmx for the 3 rd project
Why in asp.net web page we have only one FORM attribute, but in other language more than one FORM attribute is allowed.
View 3 RepliesI can open it up in the browser and it works, but a call from client side (using both jquery and asp.net ajax fails)
Service Contract
[OperationContract(Name = "GetTestString")]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json
)]
string GetTestString();
In Web.config among other bindings, I have a webHttp binding
<endpoint address="ajax" binding="webHttpBinding" contract="TestService" behaviorConfiguration="AjaxBehavior" />
EndPoint Behavior
<endpointBehaviors>
<behavior name="AjaxBehavior">
<enableWebScript/>
</behavior>
</endpointBehaviors>
</behaviors>
Svc file
<%@ ServiceHost Service="TestService" %>
Client
var serviceUrl = "http://127.0.0.1/Test.svc/ajax/";
var proxy = new ServiceProxy(serviceUrl);
How can allow this page to run on IIS server...It does not work on localhost..... it works when I open it directly... It gives the error "it is not allowed...!
The working Example..! I want this.. ""
the Erorr:
<html>
<head>
<script src="jquery.js" type="text/javascript" language="javascript"></script>
<script src="jquery.xml2json.js" type="text/javascript" language="javascript"></script>
<script>
function sayHello(msg)
{
alert(msg);
}
function dcSetRate(obj,value){
document.getElementById(obj).value = value.toFixed(4);
}
function dcSet(obj,value){
document.getElementById(obj).value = value;
}......
As far i think # is not allowed in valid url but i have to allow this in my application..very first step i have taken in reg expression i allowed # ...but wen user click that inspite of valid url i am getting crash
View 4 Repliesi am getting the error below while sending email in aps.net 3.5.
Mailbox name not allowed. The server response was: sorry, Authentication failed or timed out. Please do get messages first to authenticate yourself.(#4.4.3) in asp.net while sending mail
I have a textbox where the user must not be able to enter more than two digits after a decimal.How do I do this without using javascript?
View 3 Replies