|
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.
|
|
|
|
|
I am developing on a local machine with both sql server and visual studio installed.
Any thoughts?
|
|
|
|
|
Not as long as I have no idea what the error is. All I know is that "it doesn't work".
|
|
|
|
|
Ok, I did remove the try catch statement.
There is no exception.
I step through the code and runs line by line.
You notice that in the first post I said it executes the ssis package which means that result returns success.
Ten as I explained before, I modified the ssis and now it result.tostring() returns failure.
No exception.
Thanks
|
|
|
|
|
How to prevent deletion of files on the client side?like my documents in win xp to nt delete by user
|
|
|
|
|
azamt wrote: How to prevent deletion of files on the client side?like my documents in win xp to nt delete by user
Why would any ASP.Net application do that?
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.
|
|
|
|
|
If at first you don't succeed, repost the question
only two letters away from being an asset
|
|
|
|
|
Buy a book on ASP.NET. Look for books with the word 'dummies' in the title. Read it, and try to get a basic understanding of what ASP.NET is, and does. When you have a clue what you're working with, you'll know why there's no way you could ever hope to do this.
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.
|
|
|
|
|
Greetings ..
I sit for several hours before the problem and still can not find a suitable answer.
Javascript is not exactly my forte, so I just ask once.
I want to do the following:
I have a matrix with various Checbox. This will be filled by a database in C #. If a checkbox has been clicked, ie onclick, an inquiry should be sent to the database to read from the DataBase If click the checkbox in the matrix on C #, now is the time a database query with a WHERE = presentValue be started.
http://img17.imageshack.us/img17/760/unbenanntpw.jpg
From the database should be read out what people can C #.
My problem is mainly in the transfer the collected values of javascript in ajax so that the database sends the request to obtain an answer?
I am grateful for any information
|
|
|
|
|
Create a string contains the values using javascript and submit to server as a query string. In the server, you have to implement the logic to filter the values.
|
|
|
|
|
thanks for the answer
I create a string contains the values using javascript and submit to server as a query string. In the server, you have to implement the logic to filter the values.
I collect my values with a JavaScriptFunction
function GetAllChecked() {
var checkboxes = document.getElementsByName("skill");
var s = ""
for (var i = 0; i < checkboxes.length; i++)
if (checkboxes[i].checked)
s += checkboxes[i].value + ";"
;
;
document.getElementById("hhidAcrobat").value = S;
}
exactly what I'm doing wrong?
|
|
|
|
|
Did you debug this code? what is the value of variable s after the loop? how you submit this value to server?
|
|
|
|
|
the value of my string in Js contain "43;44;45;46;47;48;49;50;51;52;53;54;"
how should i tranfer this string to my database?
|
|
|
|
|
Post this string as a query string to the target URL using XMLHttpRequest object.
|
|
|
|
|
thx for ya idea, will try it
|
|
|
|
|
I don't know what element "skill" is, but there is no HTML element that represents a "checkboxlist" so I'm guessing it's a container for the checkboxes.
Try changing the first line to
var checkboxes = document.getElementsByName("skill").children;
If it still doesn't work, attach your debugger and use the watches to see what's in the variables. If you don't know how to do this, take the time to learn it as it'll save you a huge amount of time in the long run.
|
|
|
|