Showing posts with label write. Show all posts
Showing posts with label write. Show all posts

Thursday, March 22, 2012

The file is being used by some other process

hi ,

Am trying to read from and write to a same xml file.i have no prob when
reading the xml file.but when i write to the same file i get the following
error even after closing the reader object(which is open).

The file is being used by some other process.

regards
JagadeeshJagadeesh:

It'd help if you posted the code, but how are you reading the XML file?
DataSet.ReadXML or XMLReader? I'm guessing from your post it's the latter,
but if that's the case, why are you leaving the reader open? (I may be
misunderstanding your post, but if the reader is closed, how is it still
open?).

Let me see the code and hopefully I can be of more help.

Bill
"Jagadeesh" <jagamsc@.rediffmail.com> wrote in message
news:u$Omqfl2DHA.3196@.TK2MSFTNGP11.phx.gbl...
> hi ,
> Am trying to read from and write to a same xml file.i have no prob when
> reading the xml file.but when i write to the same file i get the following
> error even after closing the reader object(which is open).
> The file is being used by some other process.
> regards
> Jagadeesh

THE FULL CLASS

hello, i'm kinda new to ASP.NET and web development

i've read that when i write behind-code for an .aspx file it's just a partial class

is there a way to read the content of the other partial class that contains the components' declarations?

Hey,

That part of the component is generated in your Temporary ASP.NET Files (under the windows\framework\<version>) folder for your application, which is where your ASP.NET pages are compiled. This was a feature meant to make it less of a coding effort. You can still access the objects in your code-behind page without those declarations.

I don't know if the web application project template does this or still includes the controls as in 1.1...

The Global.asax.cs

does anyone know how I would write the event :

Application_BeginRequest

from the Global.asax.cs and put this into my webform as inline code?

I think the event you are looking for is ?

Sub Application_Start(ByVal senderAsObject,ByVal eAs EventArgs)

' Code that runs on application startup

EndSub


Thanks but I need it to fire on every postback, not just on application start-up, so something along the lines of (in c#):

private void Application_BeginRequest(Object Sender, EventArgs e)

{

Response.Write("test");

}

I think its the same name as the event in vb too.


you could create a .cs class that would reside in your App_Code folder and then create your function in it. Then in what ever page you need it you would:

if page.ispostback then

Dim gbFunctionsAsNew globalServerFuncitons // The name of the class

Then gbFunctions.YourFunctionNameInTheClass

end if


I guess I should have explained the problem a little more clearly.. The reason I need this event before the page is requested is because of problem with IIS 5.1 (http://support.microsoft.com/?id=910436)

I am uploading several files using file upload controls but each time a postback occurs (i.e. i submit the form) - i am sent to a dns error page because my file sizes total more than my specified limit in the web config.

I therefore am trying to catch the error before the application requests the file headers and throws you to the very unelegant dns error page as described by the microsoft article above.

SO the example workaround they have given in that article i am trying to incorporate using inline code (not code behind). The reason being is because we use several applications that I am writing the upload component for and my task was to create a single .aspx webform that kept all scripts (c#, javaScript, html) all in the one place so we can easily configure it when re-using in the many other apps we have.

Because of this issue the code will never reach the page load event, only the app start, begin request, and on error of the application (in global). So I need to program one of these into my webform.

Does all the above make sense?


So this error occurs on the client and not the server?

Tuesday, March 13, 2012

The LINQ "where" clause

Hi guys,

I'm trying to write a LINQ query in which the where clause can accept 6 parameters. The problem is that all of them are optional parameters and need to be validated as not Null or Empty in order to be used. Normally when I used the SqlCommand I would build a string for the query via conditional statements, like:

if (!String.IsNullOrEmpty(TextBox1.Text)) { SqlString +="..." }

How do I do the equivalent to that in LINQ?

Thanks in advance!

not sure if i understand what you mean. do you mean validate a statement as a parameter? In that case you can write like this with the ? syntax:

object o;

o = (cond1 = cond2 ? truevalue : falsevalue);

MyFunction( String.IsNullOrEmpty(TextBox1.Text) ? truevalue : falsevalue)


Well, this is how I did it the non-LINQ way:

string SqlString =string.Empty;if (!String.IsNullOrEmpty(TextBox1.Text)) { SqlString +="...";}if (!String.IsNullOrEmpty(TextBox2.Text)) { SqlString +="...";}SqlCommand MyCommand =new SqlCommand(SqlString, MyConnection);

In the code above I created the SqlString variable. After that I would check if the Text property is Null or Empty for the TextBox1 & TextBox2 andonly append to the SqlString if they are not. Then I run the newly built Sql query. I need to do the equivalent in LINQ and I just don't know how.