Showing posts with label aspnet. Show all posts
Showing posts with label aspnet. Show all posts

Monday, March 26, 2012

Running a asp.net(1.1) app with sql2005 (on a 2.0 framework app)

Hi,
I have developed a simple app using asp.net (vb.net 2003).
Normally I would copy the application files from
c:\Inetpub\wwwroot\
to the server and paste them to the same location on the
server.
I have installed a new server with win2k3 sp1 and installed
beta 2 of sql2005. I have tried the same copying and pasting
but when I run the application, I get the following error:
Cannot view XML input using XSL style sheet. Please correct the error
and then click the Refresh button, or try again later.
----
A name was started with an invalid character. Error processing resource
'http://localhost/webit/login.aspx'. Line 1, Posit...
<%@. Page Language="vb" AutoEventWireup="false" Codebehind="Login.aspx.vb"
Inherits="WebIT.Login"%>
-^
what should i do?
Please help.
Rgs,
MehulI think there's a problem with the IIS 6.0.
I had a sumiliar Problem and there's a discussion about it in the IIS
General UserGroup Now,waiting 4 answer.
"melu" wrote:
> Hi,
> I have developed a simple app using asp.net (vb.net 2003).
> Normally I would copy the application files from
> c:\Inetpub\wwwroot\
> to the server and paste them to the same location on the
> server.
> I have installed a new server with win2k3 sp1 and installed
> beta 2 of sql2005. I have tried the same copying and pasting
> but when I run the application, I get the following error:
>
>
> Cannot view XML input using XSL style sheet. Please correct the error
> and then click the Refresh button, or try again later.
>
> ----
> A name was started with an invalid character. Error processing resource
> 'http://localhost/webit/login.aspx'. Line 1, Posit...
> <%@. Page Language="vb" AutoEventWireup="false" Codebehind="Login.aspx.vb"
> Inherits="WebIT.Login"%>
> -^
>
> what should i do?
> Please help.
> Rgs,
> Mehul

Wednesday, March 21, 2012

Run SSIS from ASP.net

in sql 2005 sp1,
when I try to run a package from an asp.net page
the following statement generate error:
myPackage = integrationServices.LoadFromDtsServer(packagePath,
"myServerName", Nothing)
error:
EXECUTE permission denied on object 'sp_dts_getpackage', database 'msdb',
schema 'dbo'.
I followed "Kirk Haselden" instruction on how to assign permissions for
remote user but did not solve the issue.
thanks for help
what permissions should be assigned and to which user.Hello,
This issue may occur if the identity of application pool of asp.net
application does not have the proper permission on msdb database.
You may want to run inetmgr and check the identity of the Website hosting
the asp.net application. If it is "network service", you may add "nt
authortiy/network service" to login of SQL Server, and grant it proper
permission on msdb SQL Server.
Best Regards,
Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
========================================
=============
This posting is provided "AS IS" with no warranties, and confers no rights.|||I assigned "nt authortiy/network service" the right permissions on procedure
s
sp_dts_getpackage and sp_dts_listpackages, but now I'm getting another error
:
"
Only the owner of DTS Package 'myPackage' or a member of the symin role
may create new versions of it.
"
I was checking those procedure and find a check on the dts owner.
I can disable these checks, but worried that would affect something else on
the server.
any other work arround ?
thanks|||Hello,
As mentioned in the error message, you may want grant SQL server symin
role to the login to work around the issue but it may bring security risk.
Based on my scope, Usually disabling these check shall not have other
effect on the server.
Best Regards,
Peter Yang
MCSE2000/2003, MCSA, MCDBA
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
========================================
=============
This posting is provided "AS IS" with no warranties, and confers no rights.sql

Friday, March 9, 2012

Run DTS from ASP.NET (VB)

I have a DTS package which imports data from a legacy app to SQLServer 2000. Right now I have a page in classic ASP which executes a SP which in turn calls the DTS package. After the user hits the "Update" button on the ASP page they are redirected to a page that says "This process takes several minutes, check back later." The current setup is causing problems because Joe may hit the "Update" button to refresh the data and get an error because the DTS package is already running from when Mary just ran the same process.

I want to rewrite this in .NET (2.0) to accomplish the following:

    Eliminate the SPCheck the status of the DTS package and alert the user if it is already running.Show a "Please wait while we process your request" message to the person who started the update while the DTS is running.Automatically show the report when the DTS is done.

I think I can find code in the forum to execute the DTS, but how do check the current status first? I've read about SQLDMO but the Web server and SQLServer are on different machines. Would this still work?

Thanks in advance.

I'm having trouble getting the DTS execute to run asynchronously. All the examples I've found show executing queries asynchronously, but nothing on DTS (there all in C# as well). Here's what I have in my class.

Imports System.IO
Imports System.NetImports System.Net.Mail
Imports System.ThreadingImports System.Runtime.Remoting.Messaging
Imports DTS
Imports DTS.DTSSQLServerStorageFlags

PartialClass Reporting_AmSherReports_rptColStats
Inherits System.Web.UI.Page
'----------------------------
'Remember, if you change the package, these numbers will need to be modified too.
'----------------------------

Private sPkgIDAs String ="{4CFD14F0-12D8-445C-AD98-E0DD784B166A}"
Private sPkgVersionAs String ="{F0CAFA3B-9A52-4780-B0C6-5B86C38BCFC5}"
Protected sMessageAs String =""

Protected Sub Page_Load(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Me.Load
If Page.IsPostBackThen

'Show processing message...

Processing.Visible =True
Report.Visible =False
Refresh.Visible =False

Dim stateAs New Object()
Dim beginHandlerAs New BeginEventHandler(AddressOf ExecuteDTS)
Dim endHandlerAs New EndEventHandler(AddressOf DTSComplete)
Dim timeoutHandlerAs New EndEventHandler(AddressOf DTSTimeout)
Dim taskAs New PageAsyncTask(beginHandler, endHandler, timeoutHandler, state)
RegisterAsyncTask(task)
End If
End Sub

Private Function ExecuteDTS(ByVal senderAs Object,ByVal eAs EventArgs,ByVal cbAs AsyncCallback,ByVal stateAs Object)As IAsyncResult
Try
Dim sSourceAs String =""
Dim sDescAs String =""
Dim lErrAs Long
Dim oPKGAs DTS.Package =New DTS.Package
Dim oStepAs DTS.Step

'Load Package

oPKG.LoadFromSQLServer("server","sa","", DTSSQLStgFlag_UseTrustedConnection, , sPkgID, sPkgVersion,"Refresh Stats")

'Execute

oPKG.Execute()

'Get Status and Error Message

For Each oStepIn oPKG.Steps
If oStep.ExecutionResult = DTSStepExecResult.DTSStepExecResult_FailureThen
oStep.GetExecutionErrorInfo(lErr, sSource, sDesc)
sMessage = sMessage &"Step """ & oStep.Name &""" Failed" & vbCrLf & _
vbTab &"Error: " & lErr & vbCrLf & _
vbTab &"Source: " & sSource & vbCrLf & _
vbTab &"Description: " & sDesc & vbCrLf & vbCrLf
End If
Next
Catch exAs Exception
Finally
Processing.Visible =False
Report.Visible =True
Refresh.Visible =False
End Try
End Function

Private Sub DTSComplete(ByVal arAs IAsyncResult)
Processing.Visible =False
Report.Visible =True
Refresh.Visible =True
End Sub

Private Sub DTSTimeout(ByVal arAs IAsyncResult)
'No implementation -- needed for PageAsyncTask

End Sub
End Class

Wednesday, March 7, 2012

Run a SQL script file from an ASP.NET page

Hi there,

I would like to know how can I run a SQL Server 2000 script file (*.sql) from an ASP.NET page. I don't wanna run it from the SQL Query Analyzer, but run it the page itself, I mean dynamically.

Is there any object, method, or whatever to do it?

Thanks in advanceHmpf.

1: Load file into stroing variable.
2: open connection to server.
3: create SqlCommand object.

and now carefull - the HUGH trick:

4: assign string from file to CommandText property of the command.

and...

5: execute.

That simple, really.|||Hi again,

It works!

Thank you very much!|||you mean MyCommand.Execute("myFile.sql") ?
or you must do a readfile (readAll) first ?
thank you
|||it works for CREATE TABLE but for view or procedure I get

ERROR [42000] [Microsoft][ODBC SQL Server Driver][SQL Server]'CREATE VIEW' must be the first statement in a query batch.

do you know why ?
my script >>
CREATE TABLEdbo.Label
(
[id] [int] IDENTITY (1, 1) NOT NULL ,
[value] [varchar] (255) COLLATE French_CI_AS NULL ,
)
ON [PRIMARY]

CREATE VIEW dbo.Label
AS
SELECT value, id
FROM
dbo.Label
WHERE (value = '100')

thank you for helping

|||it seems that nobody knows how to run VREATE VIEW or PROCEDURE from sql file
|||You need to put a GO statement after each command.
|||no it doesn't work !
I can run a .sql file with create TABLE but not with create VIEW or PROCEDURE
|||Are you certain of your current error message? In the script youhave provided you are calling both objects you are attempting to create"Label", which is not possible. Also, you will receive an errorif the object "Label" already exists in your database when you run thescript.
|||now it works !!
thank you
but how can I insert with a procedure from queryAnalyser ?
If I run
CREATE PROCEDURE [dbo].Insert_all AS
INSERT INTO Config (nom, valeur, valide) VALUES ('langDef','0',1)
INSERT INTO Config (nom, valeur, valide) VALUES ('Login','1',1)
INSERT INTO Config (nom, valeur, valide) VALUES ('Open','1',1)
GO
nothing is inserted in my database

|||You have to EXECUTE the stored procedure in order for the commands it contains to be performed.
EXECUTE dbo.Insert_all

|||it works fine !!!:)))
thanks a ton
|||I can run it from QueryAnalyser but from ASP NET ...first iof all : I must remove the GO
then it works for CREATE TABLE
but if i add this statement >>
CREATE PROCEDURE [dbo].dt_Component
AS
DELETE FROM Component
it doesn't work ... even the tables are not created
for any pROCEDURE or VIEW it doesn't work at all


|||Quentin, it is impossible to help you when you only tell us "it doesn'twork". Certainly there must be associated error messages. Withoutthose error messages and your vague descriptions it is extremelyfrustrating to try to help you. And at this point you havesupplied us with so many varying pieces of code and scenarios that Ihave no idea what you are asking.
Could you please try again, stating exactly what code you are running,from where, and what the behavior you are seeing is, along with anyerror messages?
|||I am trying a very simple .sql file
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Config]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Config]
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[dt_Config]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[dt_Config]
CREATE TABLE [dbo].[Config] (
[id_Config] [int] IDENTITY (1, 1) NOT NULL ,
[nom] [varchar] (50) COLLATE French_CI_AS NULL ,
[valeur] [varchar] (255) COLLATE French_CI_AS NULL ,
[valide] [bit] NULL
) ON [PRIMARY]
but if I add >>
CREATE PROCEDURE [dbo].dt_Config
AS
DELETE FROM Config

it does not work ... it is just impossible to create view or procedure from ASP NET
and if I add the GO between each command it bugs at the first GO