Showing posts with label web. Show all posts
Showing posts with label web. Show all posts

Thursday, March 22, 2012

CURRENT_USER issue

I've inherited Database for a Web Application (with no support) that
makes heavy use of the following function, at least in the report views
that have been defined:
ALTER FUNCTION [dbo].[fn_UserIsSysAdmin] ()
RETURNS bit
AS
BEGIN
DECLARE @.UserId int
SET @.UserId = CAST(CURRENT_USER AS int)
DECLARE @.SysAdmin bit
SELECT @.SysAdmin = SystemAdministrator FROM Users WHERE UserId = @.UserId
-- Returns 1 if SysAdmin, 0 if normal user
RETURN @.SysAdmin
END
If you use the web application, everything runs fine.
If you try to access the report view from with SQL Management Studio, I
receive an error about not being able to convert an NVARCHAR ('dbo') to
an INT on the CAST operation above.
I understand what the above function is trying to do, but when I execute
'SELECT CURRENT_USER' from within SQL Management Studio, I get 'dbo' as
the result. Somehow, when this function is called from the Web
Application, it returns a 'username' defined in the dbo.Users table that
gets converted to an INT, which is supposed to be the exact value stored
in the UserID column for that particular record.
Sample user record:
UserID = 10001
Username = john.doe@.example.com
SystemAdministrator = 1 (true)
The function should return true in this instance, but I don't know how
that would be possible. It doesn't seem like the function should work at
all.
Any help would be greatly appreciated.
-={ Kyle K. }=-
Hi,
Instead of Current_user, can you please use function SYSTEM_USER.
Please write back if it works.
Thanks
Hari
SQL Server MVP
"Kyle K." wrote:

> I've inherited Database for a Web Application (with no support) that
> makes heavy use of the following function, at least in the report views
> that have been defined:
>
> ALTER FUNCTION [dbo].[fn_UserIsSysAdmin] ()
> RETURNS bit
> AS
> BEGIN
> DECLARE @.UserId int
> SET @.UserId = CAST(CURRENT_USER AS int)
> DECLARE @.SysAdmin bit
> SELECT @.SysAdmin = SystemAdministrator FROM Users WHERE UserId = @.UserId
> -- Returns 1 if SysAdmin, 0 if normal user
> RETURN @.SysAdmin
> END
>
> If you use the web application, everything runs fine.
> If you try to access the report view from with SQL Management Studio, I
> receive an error about not being able to convert an NVARCHAR ('dbo') to
> an INT on the CAST operation above.
> I understand what the above function is trying to do, but when I execute
> 'SELECT CURRENT_USER' from within SQL Management Studio, I get 'dbo' as
> the result. Somehow, when this function is called from the Web
> Application, it returns a 'username' defined in the dbo.Users table that
> gets converted to an INT, which is supposed to be the exact value stored
> in the UserID column for that particular record.
> Sample user record:
> UserID = 10001
> Username = john.doe@.example.com
> SystemAdministrator = 1 (true)
> The function should return true in this instance, but I don't know how
> that would be possible. It doesn't seem like the function should work at
> all.
> Any help would be greatly appreciated.
> -={ Kyle K. }=-
>
|||My guess is that you do have users in your database named in a way so the names can be converted to
int. You can see what usernames exists in the database thought the sys.database_principals catalog
view. If my assumption is correct, they written a pretty crappy function, which need to be fixed.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Kyle K." <SKyleK@.Frontiernet.net> wrote in message news:55_Ng.498$Ka1.99@.news01.roc.ny...
> I've inherited Database for a Web Application (with no support) that makes heavy use of the
> following function, at least in the report views that have been defined:
>
> ALTER FUNCTION [dbo].[fn_UserIsSysAdmin] ()
> RETURNS bit
> AS
> BEGIN
> DECLARE @.UserId int
> SET @.UserId = CAST(CURRENT_USER AS int)
> DECLARE @.SysAdmin bit
> SELECT @.SysAdmin = SystemAdministrator FROM Users WHERE UserId = @.UserId
> -- Returns 1 if SysAdmin, 0 if normal user
> RETURN @.SysAdmin
> END
>
> If you use the web application, everything runs fine.
> If you try to access the report view from with SQL Management Studio, I receive an error about not
> being able to convert an NVARCHAR ('dbo') to an INT on the CAST operation above.
> I understand what the above function is trying to do, but when I execute 'SELECT CURRENT_USER'
> from within SQL Management Studio, I get 'dbo' as the result. Somehow, when this function is
> called from the Web Application, it returns a 'username' defined in the dbo.Users table that gets
> converted to an INT, which is supposed to be the exact value stored in the UserID column for that
> particular record.
> Sample user record:
> UserID = 10001
> Username = john.doe@.example.com
> SystemAdministrator = 1 (true)
> The function should return true in this instance, but I don't know how that would be possible. It
> doesn't seem like the function should work at all.
> Any help would be greatly appreciated.
> -={ Kyle K. }=-

CURRENT_USER issue

I've inherited Database for a Web Application (with no support) that
makes heavy use of the following function, at least in the report views
that have been defined:
ALTER FUNCTION [dbo].[fn_UserIsSysAdmin] ()
RETURNS bit
AS
BEGIN
DECLARE @.UserId int
SET @.UserId = CAST(CURRENT_USER AS int)
DECLARE @.SysAdmin bit
SELECT @.SysAdmin = SystemAdministrator FROM Users WHERE UserId = @.UserId
-- Returns 1 if SysAdmin, 0 if normal user
RETURN @.SysAdmin
END
If you use the web application, everything runs fine.
If you try to access the report view from with SQL Management Studio, I
receive an error about not being able to convert an NVARCHAR ('dbo') to
an INT on the CAST operation above.
I understand what the above function is trying to do, but when I execute
'SELECT CURRENT_USER' from within SQL Management Studio, I get 'dbo' as
the result. Somehow, when this function is called from the Web
Application, it returns a 'username' defined in the dbo.Users table that
gets converted to an INT, which is supposed to be the exact value stored
in the UserID column for that particular record.
Sample user record:
UserID = 10001
Username = john.doe@.example.com
SystemAdministrator = 1 (true)
The function should return true in this instance, but I don't know how
that would be possible. It doesn't seem like the function should work at
all.
Any help would be greatly appreciated.
-={ Kyle K. }=-Hi,
Instead of Current_user, can you please use function SYSTEM_USER.
Please write back if it works.
Thanks
Hari
SQL Server MVP
"Kyle K." wrote:
> I've inherited Database for a Web Application (with no support) that
> makes heavy use of the following function, at least in the report views
> that have been defined:
>
> ALTER FUNCTION [dbo].[fn_UserIsSysAdmin] ()
> RETURNS bit
> AS
> BEGIN
> DECLARE @.UserId int
> SET @.UserId = CAST(CURRENT_USER AS int)
> DECLARE @.SysAdmin bit
> SELECT @.SysAdmin = SystemAdministrator FROM Users WHERE UserId = @.UserId
> -- Returns 1 if SysAdmin, 0 if normal user
> RETURN @.SysAdmin
> END
>
> If you use the web application, everything runs fine.
> If you try to access the report view from with SQL Management Studio, I
> receive an error about not being able to convert an NVARCHAR ('dbo') to
> an INT on the CAST operation above.
> I understand what the above function is trying to do, but when I execute
> 'SELECT CURRENT_USER' from within SQL Management Studio, I get 'dbo' as
> the result. Somehow, when this function is called from the Web
> Application, it returns a 'username' defined in the dbo.Users table that
> gets converted to an INT, which is supposed to be the exact value stored
> in the UserID column for that particular record.
> Sample user record:
> UserID = 10001
> Username = john.doe@.example.com
> SystemAdministrator = 1 (true)
> The function should return true in this instance, but I don't know how
> that would be possible. It doesn't seem like the function should work at
> all.
> Any help would be greatly appreciated.
> -={ Kyle K. }=-
>|||My guess is that you do have users in your database named in a way so the names can be converted to
int. You can see what usernames exists in the database thought the sys.database_principals catalog
view. If my assumption is correct, they written a pretty crappy function, which need to be fixed.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Kyle K." <SKyleK@.Frontiernet.net> wrote in message news:55_Ng.498$Ka1.99@.news01.roc.ny...
> I've inherited Database for a Web Application (with no support) that makes heavy use of the
> following function, at least in the report views that have been defined:
>
> ALTER FUNCTION [dbo].[fn_UserIsSysAdmin] ()
> RETURNS bit
> AS
> BEGIN
> DECLARE @.UserId int
> SET @.UserId = CAST(CURRENT_USER AS int)
> DECLARE @.SysAdmin bit
> SELECT @.SysAdmin = SystemAdministrator FROM Users WHERE UserId = @.UserId
> -- Returns 1 if SysAdmin, 0 if normal user
> RETURN @.SysAdmin
> END
>
> If you use the web application, everything runs fine.
> If you try to access the report view from with SQL Management Studio, I receive an error about not
> being able to convert an NVARCHAR ('dbo') to an INT on the CAST operation above.
> I understand what the above function is trying to do, but when I execute 'SELECT CURRENT_USER'
> from within SQL Management Studio, I get 'dbo' as the result. Somehow, when this function is
> called from the Web Application, it returns a 'username' defined in the dbo.Users table that gets
> converted to an INT, which is supposed to be the exact value stored in the UserID column for that
> particular record.
> Sample user record:
> UserID = 10001
> Username = john.doe@.example.com
> SystemAdministrator = 1 (true)
> The function should return true in this instance, but I don't know how that would be possible. It
> doesn't seem like the function should work at all.
> Any help would be greatly appreciated.
> -={ Kyle K. }=-

CURRENT_USER issue

I've inherited Database for a Web Application (with no support) that
makes heavy use of the following function, at least in the report views
that have been defined:
ALTER FUNCTION [dbo].[fn_UserIsSysAdmin] ()
RETURNS bit
AS
BEGIN
DECLARE @.UserId int
SET @.UserId = CAST(CURRENT_USER AS int)
DECLARE @.SysAdmin bit
SELECT @.SysAdmin = SystemAdministrator FROM Users WHERE UserId = @.UserId
-- Returns 1 if SysAdmin, 0 if normal user
RETURN @.SysAdmin
END
If you use the web application, everything runs fine.
If you try to access the report view from with SQL Management Studio, I
receive an error about not being able to convert an NVARCHAR ('dbo') to
an INT on the CAST operation above.
I understand what the above function is trying to do, but when I execute
'SELECT CURRENT_USER' from within SQL Management Studio, I get 'dbo' as
the result. Somehow, when this function is called from the Web
Application, it returns a 'username' defined in the dbo.Users table that
gets converted to an INT, which is supposed to be the exact value stored
in the UserID column for that particular record.
Sample user record:
UserID = 10001
Username = john.doe@.example.com
SystemAdministrator = 1 (true)
The function should return true in this instance, but I don't know how
that would be possible. It doesn't seem like the function should work at
all.
Any help would be greatly appreciated.
-={ Kyle K. }=-Hi,
Instead of Current_user, can you please use function SYSTEM_USER.
Please write back if it works.
Thanks
Hari
SQL Server MVP
"Kyle K." wrote:

> I've inherited Database for a Web Application (with no support) that
> makes heavy use of the following function, at least in the report views
> that have been defined:
>
> ALTER FUNCTION [dbo].[fn_UserIsSysAdmin] ()
> RETURNS bit
> AS
> BEGIN
> DECLARE @.UserId int
> SET @.UserId = CAST(CURRENT_USER AS int)
> DECLARE @.SysAdmin bit
> SELECT @.SysAdmin = SystemAdministrator FROM Users WHERE UserId = @.UserId
> -- Returns 1 if SysAdmin, 0 if normal user
> RETURN @.SysAdmin
> END
>
> If you use the web application, everything runs fine.
> If you try to access the report view from with SQL Management Studio, I
> receive an error about not being able to convert an NVARCHAR ('dbo') to
> an INT on the CAST operation above.
> I understand what the above function is trying to do, but when I execute
> 'SELECT CURRENT_USER' from within SQL Management Studio, I get 'dbo' as
> the result. Somehow, when this function is called from the Web
> Application, it returns a 'username' defined in the dbo.Users table that
> gets converted to an INT, which is supposed to be the exact value stored
> in the UserID column for that particular record.
> Sample user record:
> UserID = 10001
> Username = john.doe@.example.com
> SystemAdministrator = 1 (true)
> The function should return true in this instance, but I don't know how
> that would be possible. It doesn't seem like the function should work at
> all.
> Any help would be greatly appreciated.
> -={ Kyle K. }=-
>|||My guess is that you do have users in your database named in a way so the na
mes can be converted to
int. You can see what usernames exists in the database thought the sys.datab
ase_principals catalog
view. If my assumption is correct, they written a pretty crappy function, wh
ich need to be fixed.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Kyle K." <SKyleK@.Frontiernet.net> wrote in message news:55_Ng.498$Ka1.99@.news01.roc.ny...[v
bcol=seagreen]
> I've inherited Database for a Web Application (with no support) that makes
heavy use of the
> following function, at least in the report views that have been defined:
>
> ALTER FUNCTION [dbo].[fn_UserIsSysAdmin] ()
> RETURNS bit
> AS
> BEGIN
> DECLARE @.UserId int
> SET @.UserId = CAST(CURRENT_USER AS int)
> DECLARE @.SysAdmin bit
> SELECT @.SysAdmin = SystemAdministrator FROM Users WHERE UserId = @.UserId
> -- Returns 1 if SysAdmin, 0 if normal user
> RETURN @.SysAdmin
> END
>
> If you use the web application, everything runs fine.
> If you try to access the report view from with SQL Management Studio, I re
ceive an error about not
> being able to convert an NVARCHAR ('dbo') to an INT on the CAST operation
above.
> I understand what the above function is trying to do, but when I execute '
SELECT CURRENT_USER'
> from within SQL Management Studio, I get 'dbo' as the result. Somehow, whe
n this function is
> called from the Web Application, it returns a 'username' defined in the db
o.Users table that gets
> converted to an INT, which is supposed to be the exact value stored in the
UserID column for that
> particular record.
> Sample user record:
> UserID = 10001
> Username = john.doe@.example.com
> SystemAdministrator = 1 (true)
> The function should return true in this instance, but I don't know how tha
t would be possible. It
> doesn't seem like the function should work at all.
> Any help would be greatly appreciated.
> -={ Kyle K. }=-[/vbcol]

Thursday, March 8, 2012

Cubes web client

I am planning to develop a web based client for AS 2005 cubes. I am looking for some sample code/apps for jump start. I you know one please can you let me know the URL. I googled but all I found some articles

Thank you - Ashok

The CellSetGrid is open source ASP.NET based OLAP browser: http://www.sqlserveranalysisservices.com/cellsetgrid/CellSetGridIntro.htm

Saturday, February 25, 2012

Cube meta data on a web page

How do I access AS database meta data (cubes + properties) from an
asp.net page?
Hans
There are several approaches you could use.
If you are looking for documentation, then nightly you could run the OLAP
Scribe utility (which generates a .doc file) -- and the link to the .doc
file from your asp.net application. That will give you pretty extensive
documentation.
http://www.microsoft.com/downloads/d...DisplayLang=en
If all you want is populate a list, then your asp.net application can use
OLAP Schema Rowsets, see Books On line for information on the topic.
As a third approach, if you know the database you want to connect to, then
you could use the Catalog object which is exposed via ADOMD.NET (see the
ADOMD.NET documentation on how to do that).
http://www.microsoft.com/downloads/d...DisplayLang=en
Hope that helps.
Dave Wickert [MSFT]
dwickert@.online.microsoft.com
Program Manager
BI SystemsTeam
SQL BI Product Unit (Analysis Services)
This posting is provided "AS IS" with no warranties, and confers no rights.
"hansiman" <han@.sen.se> wrote in message
news:eq7au0hopksiglbe7s893v1uu3a3n1f5ui@.4ax.com...
> How do I access AS database meta data (cubes + properties) from an
> asp.net page?
> Hans

Cube meta data on a web page

How do I access AS database meta data (cubes + properties) from an
asp.net page?
HansThere are several approaches you could use.
If you are looking for documentation, then nightly you could run the OLAP
Scribe utility (which generates a .doc file) -- and the link to the .doc
file from your asp.net application. That will give you pretty extensive
documentation.
http://www.microsoft.com/downloads/...&DisplayLang=en
If all you want is populate a list, then your asp.net application can use
OLAP Schema Rowsets, see Books On line for information on the topic.
As a third approach, if you know the database you want to connect to, then
you could use the Catalog object which is exposed via ADOMD.NET (see the
ADOMD.NET documentation on how to do that).
http://www.microsoft.com/downloads/...&DisplayLang=en
Hope that helps.
--
Dave Wickert [MSFT]
dwickert@.online.microsoft.com
Program Manager
BI SystemsTeam
SQL BI Product Unit (Analysis Services)
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"hansiman" <han@.sen.se> wrote in message
news:eq7au0hopksiglbe7s893v1uu3a3n1f5ui@.
4ax.com...
> How do I access AS database meta data (cubes + properties) from an
> asp.net page?
> Hans

Sunday, February 19, 2012

CSV to SQL help

Using Visual Web Developer 2005 and VB, I have created a web form page with a datagrid that shows the data which is stored in an SQL database Table. Everything shows perfectly but it requires the data to already be in the database. Right now, I am exporting the data as a csv file, clearing the data out of the table in the database, and manually importing the csv file. What I would like is to have an Upload procedure that will automatically clear the table and input the new data into that same table without any extra measures by the user.

I created a FileUpload procedure (FileUpload1) which allows the user to browse to the file they want. I have set up a string that holds the location of that file (fi as string). I also have a Import button (btnImport) which is where I need to write the code which will take the csv file in the above location (fi) and save it to the database table I have set up. I basically want to be able to skip having to go to the SQL Server Manager and import the csv into the table whenever they need it. I also want there to be no interaction for this part by the user other than choosing the file to import.

Amy help would be greatly appreciated.

You should be able to connect directly to the csv file with and OleDbConnection and use a OleDbDataAdapter.Fill() to fill a DataSet. Once you have the dataset you can bind directly to the datagrid. Checkwww.connectionstrings.com for the correct connection string. You will need to dynamically insert the path to the file into the connection string.

-David

Tuesday, February 14, 2012

CS1595: 'Sanghi.Global' is defined in multiple

hi when i try to run my c#.net web application i m getting following
error
if any one know the solution pls let me know
Compiler Error Message: *CS1595: 'Sanghi.Global' is defined in multiple
places; using definition from
'c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary
ASP. NETFiles\sanghiweb\3cb18c71\212986e7\ass
embly\dl2\0730bee1\0028ca9a_b915
c501\sanghiweb.DLL'
*Source Error:*
Line 26:
Line 27:
[System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()]
Line 28: public class Global_asax : Sanghi.Global {
Line 29:
Line 30: private static bool __initialized = false;I think you posted in the wrong newsgroup.
Anyways, clear the temporary internet files and try.
"Mahesh" wrote:

> hi when i try to run my c#.net web application i m getting following
> error
> if any one know the solution pls let me know
> Compiler Error Message: *CS1595: 'Sanghi.Global' is defined in multiple
> places; using definition from
> 'c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary
> ASP. NETFiles\sanghiweb\3cb18c71\212986e7\ass
embly\dl2\0730bee1\0028ca9a_b9
15c501\sanghiweb.DLL'
> *Source Error:*
> Line 26:
> Line 27:
> [System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()]
> Line 28: public class Global_asax : Sanghi.Global {
> Line 29:
> Line 30: private static bool __initialized = false;
>

CrystalReportViewer check for guest login

Hi all

I have added crystalreportviewer using ASP .net (VB .net)

I was able to view the report when I run the web page on
my server. Everything seems fine on the server.

However, if I access the crystal report on a client machine,
it will prompt for guest login and password to the server machine.

I am using anonymous access for my IIS setting.
I can access the rest of the .net webpage without any problem.
However, when I enter the webpage with the crystalreportviewer,
it will prompt for guest password.

Even after I have keyed in the guest password, mutiple prompts appear again. The server event log show this error -
The server was unable to logon the Windows NT account 'IUSR_Machinename' due to the following error: Logon failure: unknown user name or bad password. The data is the error code.

After canceling the prompt a few times, it will show the page with
the report and its data but the sort tree and reportviewer
functions bar on top will show all weird marking. :(

For testing, I have tried adding just a crystalreportviewer object
on a empty webpage. I did not link the crystalreportviewer to
any .rpt file and the same prompt appear. Its seems that the
crystalreportviewer object need to be authenticated on the server
when accessing from the client machine.

I am using MS studio 2003 and IIS 5.1 on XP professional server.

Please help advice.

Thanks.
DerekHi all,

I have found the solution myself.

Give access rights to this folder
C:\Program Files\Microsoft Visual Studio .NET 2003\Crystal Reports

to the IUSR_<MACHINENAME> anonymous account.

This is because all the .net dll for crystal report is installed in
this folder. Hence the correct access should be provided to this
folder.

Regards,
Derek