|
ok for example
when i gotten the record id
i will store as
static string Record_ID = record id
so i can use it in the page functions with out declaring or retrieve the record id again
like Button_Click1 or any other funtion
So if i am not mistaken this will only work on window app am i correct ?
so now instead of storing as static i will have to
use Session["RecordID"] = record id
or once again retieve the Retrieve the ID in every function i need?
is that the way to do it?
KaKaShi HaTaKe
|
|
|
|
|
HatakeKaKaShi wrote: static string Record_ID = record id
so i can use it in the page functions with out declaring or retrieve the record id again
This is very wrong.
1 - static means it's visible to all users, that is what static does, windows or web
2 - either way, the variable does not persist between page loads anyhow, you need to use viewstate for that. session is to store values between pages, but it's better to put them on the URL if you can.
HatakeKaKaShi wrote: or once again retieve the Retrieve the ID in every function i need?
If you load the value in page load, it will remain the same for that page lifecycle. It just resets every time a page is requested. If your page shows a record, putting the id on the URL makes the most sense.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
thanks bro
But i need to store quite a number of variable if i put it all in the URL it will be very long
So i think Session variable will do right?
KaKaShi HaTaKe
|
|
|
|
|
You need to store a whole lot of variables for each user ? Why so many ? A query string can be reasonably long. Session is OK, but I try to avoid using it where I can. The thing about a querystring too is, it means the exact page can be bookmarked, as the right page will build itself from the URL.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
alright thanks bro i get when u mean. Yup i have a lot of variables some are being pass through to class function or next page. Bro another question is u dun mind.
if i declare a variable with in a function
let say
protected void button1_Click(object sender, EventArgs e)
{
string RecordID = Request.QueryString("RecordID");
Class class = new Class; //Class I Created
DataSet = class.ReturnDS(RecordID); //Function within the Class
}
if there are mutiple user using is
will the RecordID being Mix up again Showing person A Detail of B1 After both person trigger the same function?
KaKaShi HaTaKe
|
|
|
|
|
HatakeKaKaShi wrote: will the RecordID being Mix up again Showing person A Detail of B1 After both person trigger the same function?
No, each users pages get generated using different instances of this class, only statics will get mixed up between users.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Alright Thanks bro. Now i have a clear picture now.
Thanks a lot man
KaKaShi HaTaKe
|
|
|
|
|
Christian Graus wrote: either way, the variable does not persist between page loads anyhow, you need to use viewstate for that. session is to store values between pages, but it's better to put them on the URL if you can.
Correct me if I am wrong, static variables will stay alive until the application domain unloads and will persist across post-backs.
|
|
|
|
|
Hi..
1) I was trying to create a IF Condition in stored procedure where i need to compare if old value and new value is present/not present in the database. Dont know the Syntax to write the above said query in Stored procedure.
2) I have created a variabl name 'add', 'change', 'remove'. The old value and new value are two different columns in the table. What i want is : If old value is null and new value is present then 'add' get incremented by 1, if old value is present and it has been modified in new value and if the old value string does not match with the new value then 'change' get incremented by 1, if old value is present and it has bee deleted in new value then 'remove' get incremented by 1.
Kindly help me out as early as possible as these is where i stuck for the last few days and i need to resolve this soon.
Abhishek
|
|
|
|
|
1 - is a SQL question. The books online that come with SQL Server will answer it, too
2 - this is still question 1 ?
Abhishek Boga wrote: Kindly help me out as early as possible as these is where i stuck for the last few days and i need to resolve this soon.
You've spent a couple of days, what have you tried ? What research did you do ? Where are you at ? Why not tell us instead of asking us to start from scratch ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
hi,
if you are using any id field in the table then write a select query using that id and value and find if the column value is null, if null then insert record,if not null then find whether old value and new are equal if not then update,if new value is null then delete the record, thats it
praveen.
|
|
|
|
|
Hi
I am using impersonation in asp.net web application because I need to write on a network drive. It works fine if I use a set of credentials on shareA path, but imersonation fails for another credentials set. The users are in different domains and netwrok drives to access are different too.
For the second set credential, it is failing to load the webpage itself. The error it gives is
Line 67: <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
Line 68: </httpModules>
Line 69: <identity impersonate="true" userName="i\user" password="xxxxxxxx"/>
Line 70: </system.web>
Line 71: <system.codedom>
Any ideas what permissions might be missing for i\user? Please advise.
THanks
Pankaj
|
|
|
|
|
Hi all. I'm new to developing web applications and have a question regarding the app_data directory and publishing. I'm using VS2008, developing the application using asp, and I've incorporated the CreateUserWizard, which uses the ASPNETDB.mdf file. If I make the app live now and a user creates a login, s/he will be added to the database. I'm thinking that if I make changes to the app locally and need to publish again to the server that the .mdf file in the app_data directory gets overwritten, as all files will, causing all previously registered users to be lost. Is this the case?
What should I do to keep the .mdf file on the server in tact? Like I said, I'm new to this whole thing, so any publishing/deployment advice would be appreciated!
Brian
|
|
|
|
|
If nothing changed on DB, no need to upload it again. If you want to make any changes on DB, download it, then make the changes and upload it.
|
|
|
|
|
Hi Friends,
I am saving a file in the form of xml inside a folder into the server.
Now i want to retrieve all the xml files from folder which are stored into the server using javascript.
Any solution for to achieve this.
Thanks in Advance.
modified on Wednesday, October 7, 2009 10:26 AM
|
|
|
|
|
dayakar_dn wrote: using javascript
Not exactly. Javascript is a client side technology.
You may rather use Javascript to call a webservice which would return you the xml file(s).
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Hi,
I have created a SSIS package with the following task:
1-Execute a SQL Task to delete the data in a table
I can execute this package from ASP.NET and all seems fine.
Now i have modified the SSIS package by adding a control flow which imports data from excel into the deleted table in step 1.
The ssis package on it's own works fine.
Now I try once again to execute the ssis package from ASp.NET.
I get a failure and i know the problem is to do with the excel connection but can not figure out what needs to be edited in the code to correct this issue.
here is the code to execute the ssis package from ASp.NET in C#
I have indicated where the problem seems to be.
Any thoughts please?
protected void btnExecute_Click(object sender, EventArgs e)
{
Application app = new Application();
Package package = null;
try
{
string fileName =
Server.MapPath(System.IO.Path.GetFileName(FileUpload1.PostedFile.FileName.ToString()));
FileUpload1.PostedFile.SaveAs(fileName);
//Load DTSX
package = app.LoadPackage(@"C:\Work\Package1.dtsx", null);
//Global Package Variable
Variables vars = package.Variables;
vars["Business_ID"].Value = txtBusinessID.Text;
vars["Business_Name"].Value = txtBusinessName.Text;
//PROBLEM is on this connectionstring for eacel...
//Specify Excel Connection From DTSX Connection Manager
package.Connections["SourceConnectionExcel"].ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileName + ";Extended Properties=Excel 8.0;";
//Execute DTSX.
Microsoft.SqlServer.Dts.Runtime.DTSExecResult results = package.Execute();
lblResult.Text = results.ToString();
}
catch (Exception ex)
{
throw ex;
}
finally
{
package.Dispose();
package = null;
}
}
|
|
|
|
|
The first thing to check is what "fileName" actually contains. Unless the server is on the same machine as the one executing the application containing your code, the path must of course be a network path and not a local-machine path. If they are on the same machine, it will at least need to be a rooted path (e.g. c:\toto\files\file.tata, not files\file.tata).
Also, on an aside, you may want to remove that catch block. First of all it's a waste of space as it doesn't do anything. Worse, when you rethrow like that you rewrite the entire stack trace. Therefore, whereever in your try block or something the try-block calls into an exception is thrown, the rethrown exception will only refer to the line "throw ex", which is rather less useful!
|
|
|
|
|
filename contains:
c:\work\filename.xls
The problem still remains.
modified on Wednesday, October 7, 2009 10:18 AM
|
|
|
|
|
Which is a local-machine path. So unless Sql Server and the web server are both on the same machine that isn't going to work. (You didn't say if they are.)
It shouldn't be necessary to mention this, and please don't take offense: If the file is on the client computer it's obviously also not going to work. You can of course let a user upload a file to the web server and then use it there.
In general, the spreadsheet file needs to be in a location where Sql Server can reach it, and referred to with the correct path from Sql Server's point of view. In general, you probably want your application to work whether the Sql Server instance is running locally or on another computer (your app after all probably only knows what connection string it is using).
If it is an uploaded file you may want to create a shared folder on the web server, set up with the right permissions so Sql Server can access it. You can go the other way and put the file on the machine Sql Server is on, but I believe this would require impersonation since by default the asp.net user is a local machine user that cannot use any network resources (for security reasons; should your app be compromised in some way, at least the entire network isn't at risk).
|
|
|
|
|
Btw did you remove the catch block? If so, what's the stacktrace in the exception you're getting? Just to know if it even gets to the "Execute" step...
|
|
|
|
|
There is no error in the code.
It just returns failure (As mentioned before).
|
|
|
|
|
The method returns void, not failure. So there must be an exception if you get any notice of a failure. Attach a debugger and find out what's happening.
|
|
|
|
|
If you look closely you will see, results.ToString();
It returns failure or success.
I step through t he code and see the failure.
|
|
|
|
|
protected void btnExecute_Click(object sender, EventArgs e)
It returns void. It assigns a value to the text of a label, if it ever gets to that statement.
If you cannot be bothered to do simple things I ask for so that I can help you, like remove the catch block and tell me if you get an exception and if so what the stack trace is, I am not sure I can see why I should bother trying to help.
|
|
|
|