Showing posts with label user. Show all posts
Showing posts with label user. Show all posts

Thursday, March 29, 2012

Case Statements

Can anyone help me with the case statements?
I have customized a new report for our application (vendor software). I want the end user to check 3 boxes to print (they can choose all or one or two).

Below is the case statement I tired in the where clause

Where
STATUS = CASE
WHEN REPORT.SEPARATED = 'y' THEN 'S'
WHEN REPORT.TERMINATED = 'y' THEN 'T'
WHEN REPORT.RETIRED ='y' THEN 'R'
END

I want the user to check one box , two or 3 . Rightnow it is working fine if any one option is checked. Please let me if there is any other way to do this.

many thanks

Quote:

Originally Posted by anishap

Can anyone help me with the case statements?
I have customized a new report for our application (vendor software). I want the end user to check 3 boxes to print (they can choose all or one or two).

Below is the case statement I tired in the where clause

Where
STATUS = CASE
WHEN REPORT.SEPARATED = 'y' THEN 'S'
WHEN REPORT.TERMINATED = 'y' THEN 'T'
WHEN REPORT.RETIRED ='y' THEN 'R'
END

I want the user to check one box , two or 3 . Rightnow it is working fine if any one option is checked. Please let me if there is any other way to do this.

many thanks


i think this would be better if you build the WHERE from your form/gui. you have might have to adjust the returned value of your checkbox. depending on your front-end tool.

something like

queryvar = queryvar + ' WHERE STATUS IN ('
for counter = numbercheckbox
if checkbox is checked
queryvar = queryvar + returnedvalueofcheckbox

queryvar = queryvar + ')'

this is a psedocode. am suggesting the technique, not the syntax. depending on your gui, you're going to have to adjust it accordingly

Tuesday, March 27, 2012

CASE Statement

Hello,
I have a varchar field (ApprovalStatus) that can have 3 results (Approved,
Denied or NULL). On my web page, I have a dropdown box which the user can
select 3 items (Approved, Denied or Pending). When they choose "Pending",
I want to retrieve the fields that are NULL. I've tried the following WHERE
statement, but I can't capture the NULL fields.
@.strParm03 can equal "All, Approved, Denied or NULL)
WHERE
ApprovalStatus LIKE CASE @.strParm03 WHEN 'all' THEN '%'
WHEN 'Pending' THEN NULL
ELSE @.strParm03 END
Any help with this would be appreciated.
Thanks in advance,
sck10
I would use a script like:
[code]
where @.strParm03 = 'All'
or (@.strParm03='Approved' and ApprovalStatus='Approved')
or (@.strParm03='Denied' and ApprovalStatus='Denied')
or (@.strParm03='Pending' and ApprovalStatus is null)
[/code]
or
[code]
where @.strParm03 = 'All'
or (@.strParm03='Approved' and ApprovalStatus='Approved')
or (@.strParm03='Denied' and ApprovalStatus='Denied')
or (@.strParm03='Pending' and isnull(ApprovalStatus,'') ='')
[/code]
HTH,
Cristian Lefter, SQL Server MVP
"sck10" <sck10@.online.nospam> wrote in message
news:Oafy0raXFHA.3032@.TK2MSFTNGP10.phx.gbl...
> Hello,
> I have a varchar field (ApprovalStatus) that can have 3 results (Approved,
> Denied or NULL). On my web page, I have a dropdown box which the user can
> select 3 items (Approved, Denied or Pending). When they choose
> "Pending",
> I want to retrieve the fields that are NULL. I've tried the following
> WHERE
> statement, but I can't capture the NULL fields.
> @.strParm03 can equal "All, Approved, Denied or NULL)
> WHERE
> ApprovalStatus LIKE CASE @.strParm03 WHEN 'all' THEN '%'
> WHEN 'Pending' THEN NULL
> ELSE @.strParm03 END
> Any help with this would be appreciated.
> --
> Thanks in advance,
> sck10
>

CASE Statement

Hello,
I have a varchar field (ApprovalStatus) that can have 3 results (Approved,
Denied or NULL). On my web page, I have a dropdown box which the user can
select 3 items (Approved, Denied or Pending). When they choose "Pending",
I want to retrieve the fields that are NULL. I've tried the following WHERE
statement, but I can't capture the NULL fields.
@.strParm03 can equal "All, Approved, Denied or NULL)
WHERE
ApprovalStatus LIKE CASE @.strParm03 WHEN 'all' THEN '%'
WHEN 'Pending' THEN NULL
ELSE @.strParm03 END
Any help with this would be appreciated.
--
Thanks in advance,
sck10I would use a script like:
[code]
where @.strParm03 = 'All'
or (@.strParm03='Approved' and ApprovalStatus='Approved')
or (@.strParm03='Denied' and ApprovalStatus='Denied')
or (@.strParm03='Pending' and ApprovalStatus is null)
[/code]
or
[code]
where @.strParm03 = 'All'
or (@.strParm03='Approved' and ApprovalStatus='Approved')
or (@.strParm03='Denied' and ApprovalStatus='Denied')
or (@.strParm03='Pending' and isnull(ApprovalStatus,'') ='')
[/code]
HTH,
Cristian Lefter, SQL Server MVP
"sck10" <sck10@.online.nospam> wrote in message
news:Oafy0raXFHA.3032@.TK2MSFTNGP10.phx.gbl...
> Hello,
> I have a varchar field (ApprovalStatus) that can have 3 results (Approved,
> Denied or NULL). On my web page, I have a dropdown box which the user can
> select 3 items (Approved, Denied or Pending). When they choose
> "Pending",
> I want to retrieve the fields that are NULL. I've tried the following
> WHERE
> statement, but I can't capture the NULL fields.
> @.strParm03 can equal "All, Approved, Denied or NULL)
> WHERE
> ApprovalStatus LIKE CASE @.strParm03 WHEN 'all' THEN '%'
> WHEN 'Pending' THEN NULL
> ELSE @.strParm03 END
> Any help with this would be appreciated.
> --
> Thanks in advance,
> sck10
>

Case sensitivity error!

Hi,
1] I have a domain user group 'Domain_name \my group' added into my SQL
Server.
2] When I execute the following code ..
if not exists (select * from master.dbo.syslogins where loginname = N'Domain_name\My Group')
exec sp_grantlogin N'Domain_name\My Group'
exec sp_defaultdb N'Domain_name\My Group', N'master'
exec sp_defaultlanguage N'Domain_name\My Group', N'us_english'
GO
I receive a error..
Error 15401
Windows NT user or group 'Domain_name\My Group not found.
Check the name again.
I just changed the code where ever *My Group* was there to *my group* then
the query was success.
I have gone through the article below but it dint answer my doubt.
http://support.microsoft.com/kb/q245768/
The server collation is Latin1_General_BIN
What is happening and what is the other way if I dont have to modify the code?
Thanks
ReddiYou have a binary collation (very unusual, btw) which is also case sensitive.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"Reddi" <Reddi@.discussions.microsoft.com> wrote in message
news:D0ACD235-3F0D-4D56-BAA5-562E88C22939@.microsoft.com...
> Hi,
> 1] I have a domain user group 'Domain_name \my group' added into my SQL
> Server.
> 2] When I execute the following code ..
> if not exists (select * from master.dbo.syslogins where loginname => N'Domain_name\My Group')
> exec sp_grantlogin N'Domain_name\My Group'
> exec sp_defaultdb N'Domain_name\My Group', N'master'
> exec sp_defaultlanguage N'Domain_name\My Group', N'us_english'
> GO
> I receive a error..
> Error 15401
> Windows NT user or group 'Domain_name\My Group not found.
> Check the name again.
> I just changed the code where ever *My Group* was there to *my group* then
> the query was success.
> I have gone through the article below but it dint answer my doubt.
> http://support.microsoft.com/kb/q245768/
> The server collation is Latin1_General_BIN
> What is happening and what is the other way if I dont have to modify the code?
> Thanks
> Reddi
>|||> The server collation is Latin1_General_BIN
I'm not completely sure about this, but it looks as if the BIN collation
means that you're dealing with a SQLServer instance which is case sensitive.
It's rare that this is required, as Windows isn't case sensitive.
As for turning SQLServer from case sensitive to case insensitive, I've never
tried it. I'd be surprised if it were possible though...
Griff|||> As for turning SQLServer from case sensitive to case insensitive, I've never
> tried it. I'd be surprised if it were possible though...
You need to rebuild the system databases using rebuildm.exe, which means you lose all stuff in the
system databases. Also, this doesn't change the collation for the user databases.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"Griff" <Howling@.The.Moon> wrote in message news:uiyxm0w8EHA.3988@.TK2MSFTNGP10.phx.gbl...
>> The server collation is Latin1_General_BIN
> I'm not completely sure about this, but it looks as if the BIN collation
> means that you're dealing with a SQLServer instance which is case sensitive.
> It's rare that this is required, as Windows isn't case sensitive.
> As for turning SQLServer from case sensitive to case insensitive, I've never
> tried it. I'd be surprised if it were possible though...
> Griff
>|||Hi Tibor,
Thanks for the response. Correct me if i am off track. If the issue is with
collaltion (case sensitivity), SQL server should not have allowed adding the
Windows NT group with wrong case in the first place as pointed by me in the
URL.
I have other server with same collation settings but it has Windows NT group
as Domain_name\My Group. I need not have to make any code change as what is
mentioned in code is matching with the group.
Thanks
Reddi
"Tibor Karaszi" wrote:
> > As for turning SQLServer from case sensitive to case insensitive, I've never
> > tried it. I'd be surprised if it were possible though...
> You need to rebuild the system databases using rebuildm.exe, which means you lose all stuff in the
> system databases. Also, this doesn't change the collation for the user databases.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> http://www.sqlug.se/
>
> "Griff" <Howling@.The.Moon> wrote in message news:uiyxm0w8EHA.3988@.TK2MSFTNGP10.phx.gbl...
> >> The server collation is Latin1_General_BIN
> >
> > I'm not completely sure about this, but it looks as if the BIN collation
> > means that you're dealing with a SQLServer instance which is case sensitive.
> >
> > It's rare that this is required, as Windows isn't case sensitive.
> >
> > As for turning SQLServer from case sensitive to case insensitive, I've never
> > tried it. I'd be surprised if it were possible though...
> >
> > Griff
> >
> >
>
>|||You could try rewriting your code to make it case-insensitive. How about
the following (not tested at all):
DECLARE @.ln nvarchar(100)
select @.ln = loginname from master.dbo.syslogins where loginname COLLATE
SQL_Latin1_General_CP1_CI_AS = N'Domain_name\My Group'
if not @.ln is null
BEGIN
exec sp_grantlogin @.ln
exec sp_defaultdb @.ln, N'master'
exec sp_defaultlanguage @.ln, N'us_english'
END
Note that I added BEGIN and END because in the original the second and third
lines were being executed unconditionally.
HTH,
Mike
"Reddi" <Reddi@.discussions.microsoft.com> wrote in message
news:D0ACD235-3F0D-4D56-BAA5-562E88C22939@.microsoft.com...
> Hi,
> 1] I have a domain user group 'Domain_name \my group' added into my SQL
> Server.
> 2] When I execute the following code ..
> if not exists (select * from master.dbo.syslogins where loginname => N'Domain_name\My Group')
> exec sp_grantlogin N'Domain_name\My Group'
> exec sp_defaultdb N'Domain_name\My Group', N'master'
> exec sp_defaultlanguage N'Domain_name\My Group', N'us_english'
> GO
> I receive a error..
> Error 15401
> Windows NT user or group 'Domain_name\My Group not found.
> Check the name again.
> I just changed the code where ever *My Group* was there to *my group* then
> the query was success.
> I have gone through the article below but it dint answer my doubt.
> http://support.microsoft.com/kb/q245768/
> The server collation is Latin1_General_BIN
> What is happening and what is the other way if I dont have to modify the
> code?
> Thanks
> Reddi
>

Case sensitivity error!

Hi,
1] I have a domain user group 'Domain_name \my group' added into my SQL
Server.
2] When I execute the following code ..
if not exists (select * from master.dbo.syslogins where loginname =
N'Domain_name\My Group')
exec sp_grantlogin N'Domain_name\My Group'
exec sp_defaultdb N'Domain_name\My Group', N'master'
exec sp_defaultlanguage N'Domain_name\My Group', N'us_english'
GO
I receive a error..
Error 15401
Windows NT user or group 'Domain_name\My Group not found.
Check the name again.
I just changed the code where ever *My Group* was there to *my group* then
the query was success.
I have gone through the article below but it dint answer my doubt.
http://support.microsoft.com/kb/q245768/
The server collation is Latin1_General_BIN
What is happening and what is the other way if I dont have to modify the code?
Thanks
Reddi
You have a binary collation (very unusual, btw) which is also case sensitive.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"Reddi" <Reddi@.discussions.microsoft.com> wrote in message
news:D0ACD235-3F0D-4D56-BAA5-562E88C22939@.microsoft.com...
> Hi,
> 1] I have a domain user group 'Domain_name \my group' added into my SQL
> Server.
> 2] When I execute the following code ..
> if not exists (select * from master.dbo.syslogins where loginname =
> N'Domain_name\My Group')
> exec sp_grantlogin N'Domain_name\My Group'
> exec sp_defaultdb N'Domain_name\My Group', N'master'
> exec sp_defaultlanguage N'Domain_name\My Group', N'us_english'
> GO
> I receive a error..
> Error 15401
> Windows NT user or group 'Domain_name\My Group not found.
> Check the name again.
> I just changed the code where ever *My Group* was there to *my group* then
> the query was success.
> I have gone through the article below but it dint answer my doubt.
> http://support.microsoft.com/kb/q245768/
> The server collation is Latin1_General_BIN
> What is happening and what is the other way if I dont have to modify the code?
> Thanks
> Reddi
>
|||> The server collation is Latin1_General_BIN
I'm not completely sure about this, but it looks as if the BIN collation
means that you're dealing with a SQLServer instance which is case sensitive.
It's rare that this is required, as Windows isn't case sensitive.
As for turning SQLServer from case sensitive to case insensitive, I've never
tried it. I'd be surprised if it were possible though...
Griff
|||> As for turning SQLServer from case sensitive to case insensitive, I've never
> tried it. I'd be surprised if it were possible though...
You need to rebuild the system databases using rebuildm.exe, which means you lose all stuff in the
system databases. Also, this doesn't change the collation for the user databases.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"Griff" <Howling@.The.Moon> wrote in message news:uiyxm0w8EHA.3988@.TK2MSFTNGP10.phx.gbl...
> I'm not completely sure about this, but it looks as if the BIN collation
> means that you're dealing with a SQLServer instance which is case sensitive.
> It's rare that this is required, as Windows isn't case sensitive.
> As for turning SQLServer from case sensitive to case insensitive, I've never
> tried it. I'd be surprised if it were possible though...
> Griff
>
|||Hi Tibor,
Thanks for the response. Correct me if i am off track. If the issue is with
collaltion (case sensitivity), SQL server should not have allowed adding the
Windows NT group with wrong case in the first place as pointed by me in the
URL.
I have other server with same collation settings but it has Windows NT group
as Domain_name\My Group. I need not have to make any code change as what is
mentioned in code is matching with the group.
Thanks
Reddi
"Tibor Karaszi" wrote:

> You need to rebuild the system databases using rebuildm.exe, which means you lose all stuff in the
> system databases. Also, this doesn't change the collation for the user databases.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> http://www.sqlug.se/
>
> "Griff" <Howling@.The.Moon> wrote in message news:uiyxm0w8EHA.3988@.TK2MSFTNGP10.phx.gbl...
>
>
|||You could try rewriting your code to make it case-insensitive. How about
the following (not tested at all):
DECLARE @.ln nvarchar(100)
select @.ln = loginname from master.dbo.syslogins where loginname COLLATE
SQL_Latin1_General_CP1_CI_AS = N'Domain_name\My Group'
if not @.ln is null
BEGIN
exec sp_grantlogin @.ln
exec sp_defaultdb @.ln, N'master'
exec sp_defaultlanguage @.ln, N'us_english'
END
Note that I added BEGIN and END because in the original the second and third
lines were being executed unconditionally.
HTH,
Mike
"Reddi" <Reddi@.discussions.microsoft.com> wrote in message
news:D0ACD235-3F0D-4D56-BAA5-562E88C22939@.microsoft.com...
> Hi,
> 1] I have a domain user group 'Domain_name \my group' added into my SQL
> Server.
> 2] When I execute the following code ..
> if not exists (select * from master.dbo.syslogins where loginname =
> N'Domain_name\My Group')
> exec sp_grantlogin N'Domain_name\My Group'
> exec sp_defaultdb N'Domain_name\My Group', N'master'
> exec sp_defaultlanguage N'Domain_name\My Group', N'us_english'
> GO
> I receive a error..
> Error 15401
> Windows NT user or group 'Domain_name\My Group not found.
> Check the name again.
> I just changed the code where ever *My Group* was there to *my group* then
> the query was success.
> I have gone through the article below but it dint answer my doubt.
> http://support.microsoft.com/kb/q245768/
> The server collation is Latin1_General_BIN
> What is happening and what is the other way if I dont have to modify the
> code?
> Thanks
> Reddi
>

Case sensitivity error!

Hi,
1] I have a domain user group 'Domain_name \my group' added into my SQL
Server.
2] When I execute the following code ..
if not exists (select * from master.dbo.syslogins where loginname =
N'Domain_name\My Group')
exec sp_grantlogin N'Domain_name\My Group'
exec sp_defaultdb N'Domain_name\My Group', N'master'
exec sp_defaultlanguage N'Domain_name\My Group', N'us_english'
GO
I receive a error..
Error 15401
Windows NT user or group 'Domain_name\My Group not found.
Check the name again.
I just changed the code where ever *My Group* was there to *my group* then
the query was success.
I have gone through the article below but it dint answer my doubt.
http://support.microsoft.com/kb/q245768/
The server collation is Latin1_General_BIN
What is happening and what is the other way if I dont have to modify the cod
e?
Thanks
ReddiYou have a binary collation (very unusual, btw) which is also case sensitive
.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"Reddi" <Reddi@.discussions.microsoft.com> wrote in message
news:D0ACD235-3F0D-4D56-BAA5-562E88C22939@.microsoft.com...
> Hi,
> 1] I have a domain user group 'Domain_name \my group' added into my SQL
> Server.
> 2] When I execute the following code ..
> if not exists (select * from master.dbo.syslogins where loginname =
> N'Domain_name\My Group')
> exec sp_grantlogin N'Domain_name\My Group'
> exec sp_defaultdb N'Domain_name\My Group', N'master'
> exec sp_defaultlanguage N'Domain_name\My Group', N'us_english'
> GO
> I receive a error..
> Error 15401
> Windows NT user or group 'Domain_name\My Group not found.
> Check the name again.
> I just changed the code where ever *My Group* was there to *my group* then
> the query was success.
> I have gone through the article below but it dint answer my doubt.
> http://support.microsoft.com/kb/q245768/
> The server collation is Latin1_General_BIN
> What is happening and what is the other way if I dont have to modify the c
ode?
> Thanks
> Reddi
>|||> The server collation is Latin1_General_BIN
I'm not completely sure about this, but it looks as if the BIN collation
means that you're dealing with a SQLServer instance which is case sensitive.
It's rare that this is required, as Windows isn't case sensitive.
As for turning SQLServer from case sensitive to case insensitive, I've never
tried it. I'd be surprised if it were possible though...
Griff|||> As for turning SQLServer from case sensitive to case insensitive, I've nevern">
> tried it. I'd be surprised if it were possible though...
You need to rebuild the system databases using rebuildm.exe, which means you
lose all stuff in the
system databases. Also, this doesn't change the collation for the user datab
ases.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
http://www.sqlug.se/
"Griff" <Howling@.The.Moon> wrote in message news:uiyxm0w8EHA.3988@.TK2MSFTNGP10.phx.gbl...[vb
col=seagreen]
> I'm not completely sure about this, but it looks as if the BIN collation
> means that you're dealing with a SQLServer instance which is case sensitiv
e.
> It's rare that this is required, as Windows isn't case sensitive.
> As for turning SQLServer from case sensitive to case insensitive, I've nev
er
> tried it. I'd be surprised if it were possible though...
> Griff
>[/vbcol]|||Hi Tibor,
Thanks for the response. Correct me if i am off track. If the issue is with
collaltion (case sensitivity), SQL server should not have allowed adding the
Windows NT group with wrong case in the first place as pointed by me in the
URL.
I have other server with same collation settings but it has Windows NT group
as Domain_name\My Group. I need not have to make any code change as what is
mentioned in code is matching with the group.
Thanks
Reddi
"Tibor Karaszi" wrote:

> You need to rebuild the system databases using rebuildm.exe, which means y
ou lose all stuff in the
> system databases. Also, this doesn't change the collation for the user dat
abases.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> http://www.sqlug.se/
>
> "Griff" <Howling@.The.Moon> wrote in message news:uiyxm0w8EHA.3988@.TK2MSFTN
GP10.phx.gbl...
>
>|||You could try rewriting your code to make it case-insensitive. How about
the following (not tested at all):
DECLARE @.ln nvarchar(100)
select @.ln = loginname from master.dbo.syslogins where loginname COLLATE
SQL_Latin1_General_CP1_CI_AS = N'Domain_name\My Group'
if not @.ln is null
BEGIN
exec sp_grantlogin @.ln
exec sp_defaultdb @.ln, N'master'
exec sp_defaultlanguage @.ln, N'us_english'
END
Note that I added BEGIN and END because in the original the second and third
lines were being executed unconditionally.
HTH,
Mike
"Reddi" <Reddi@.discussions.microsoft.com> wrote in message
news:D0ACD235-3F0D-4D56-BAA5-562E88C22939@.microsoft.com...
> Hi,
> 1] I have a domain user group 'Domain_name \my group' added into my SQL
> Server.
> 2] When I execute the following code ..
> if not exists (select * from master.dbo.syslogins where loginname =
> N'Domain_name\My Group')
> exec sp_grantlogin N'Domain_name\My Group'
> exec sp_defaultdb N'Domain_name\My Group', N'master'
> exec sp_defaultlanguage N'Domain_name\My Group', N'us_english'
> GO
> I receive a error..
> Error 15401
> Windows NT user or group 'Domain_name\My Group not found.
> Check the name again.
> I just changed the code where ever *My Group* was there to *my group* then
> the query was success.
> I have gone through the article below but it dint answer my doubt.
> http://support.microsoft.com/kb/q245768/
> The server collation is Latin1_General_BIN
> What is happening and what is the other way if I dont have to modify the
> code?
> Thanks
> Reddi
>

Sunday, March 25, 2012

Case Sensitive?

Dear everyone,

I am doing Login webform (C# .NET web application) with SQL Server 2000.

The staff table is to store authenticated user info.

But when I test it, I found that the password can be case insensitive, i.e. 'A0001' should be correct password, but 'a0001' can allow login.

Could anyone tell me how to solve this problem??

Thanks you very much!!


private void btnLogin_Click(object sender, System.EventArgs e)
{
//instantiate SQL connection
SqlConnection sqlConnect = new SqlConnection(connectStg);
SqlCommand selectLogin = sqlConnect.CreateCommand();

selectLogin.CommandText = "SELECT sid, type from STAFF Where sid= '" + txtId.Text + "' and pwd= '" + txtPwd.Text + "' ";

//open connectin for execution
sqlConnect.Open();

//instantiate the SqlDataReader reader
SqlDataReader loginReader = selectLogin.ExecuteReader();

//try and catch SqlException error
try
{
if(loginReader.Read())
{

// check whether the user is the role of administrator or operator
// I use GetValue(1) i.e. type field from the above select statement // if "O' then go operator page, else go to administrator page.
if (loginReader.GetValue(1).ToString().ToUpper().Equals("O"))
{
Server.Transfer("//SMS/LoginUser/SuccessLoginOper.aspx");

}
else if (loginReader.GetValue(1).ToString().ToUpper().Equals("A"))
{
Server.Transfer("//SMS/LoginUser/SuccessLoginAdmin.aspx");
}

}

else
{
//clear content of textbox and display error message
txtId.Text="";
txtPwd.Text="";
lblLoginFail.Visible = true;
lblLoginFail.Text="Login Failed!<br>" + "Ensure that ID and Password are correct!";
}

}
catch (SqlException se)
{
if (se.Number == 17)
{
lblLoginFail.Visible = true;
lblLoginFail.Text = "Could not connect to the database";
}

else
{
lblLoginFail.Visible = true;
lblLoginFail.Text = se.Message;
}

}

//close SqlDataReader and SqlConnection
loginReader.Close();
sqlConnect.Close();

You can alter the database to be case sensitive, and I think you can also do that on a per connection basis - but you'd have to check that. The other way could be to return the passwords that have matched and then double check them in c#. I sure someone has a better method.|||Case-sesitivity is determined when installing SQL Server,
try running sp_help to see the current settings.
Passwords shouldn't be stored in plaintext in the database
anyway. I suggest you have a look at the hashing functions
in .Net and use them to calculate a hash and then save that
in the database.
Then you wouldn't have to worry about case-sensitivity either.|||Thanks you for reply!!

As you said running sp_help to see the current settings, how to change the current settings of case-sensitive problems.

I recognise that the passwords should be better stored in encrypted forms. But how to encrypt it in SQL Server. I am new in web development. Could you briefly tell me how to do? Or any web reference provided?

Waiting for reply! Thanks

Roy|||::As you said running sp_help to see the current settings, how to change the current settings
::of case-sensitive problems

He DID tell you it is determined on install time. So you can not change it.

::I recognise that the passwords should be better stored in encrypted forms.

Good. You are wrong, though. Storing encrypted passwords in SQL Server is as bad as storing them plain text. Hashing is not encryption.

::But how to encrypt it in SQL Server.

Why should you?

Hash (not encrypt) the passwords on the website, then store he hashed passwords in the server.

In the SQL only ask for the user's data by user name, retrieve the password hash from the server, hash the user input and compare. Do not forget to salt your hashes, as otherwise you are totally open to a dictionary attack.

::I am new in web development.

Not to development in general? Sounds more like this. I would suggest you invest heavily into some books.|||First of all you should be aware that the case-sensitivity settings are GLOBAL to the entire SQL Server and all databases on it.
If you really want to to the change you have to rebuild the master database using
Rebuildm.exe.
Do look it up in the books online first, and don't forget to backup your database before!

For hashing password have a look at the classes:
System.Security.Cryptography.MD5
or preferrably
System.Security.Cryptography.SHA1

Thursday, March 22, 2012

Case sensetive column

I create an user table . I have an column userName . I want to make case sensetive to data of userName column .

Check out the the last post in this thread:http://forums.asp.net/p/1050454/1483491.aspx

Case insensitivity problem

I have an application that needs to check users' log on credentials from a
web front end.
The web front end passes the user name and password to a stored procedure
and, if the stored procedure finds someone with those credentials then it
returns the user's ID.
Trouble is that SQLServer has been installed to be case insensitive, so
"password" = "PASSWORD"
Is there anything that I can do in the stored procedure that can make the
select statement case sensitive for this particular query?
Thanks
Griff> Is there anything that I can do in the stored procedure that can make the
> select statement case sensitive for this particular query?
Of course.
http://www.aspfaq.com/2152|||http://vyaskn.tripod.com/case_sensi..._sql_server.htm
Adam Machanic
SQL Server MVP
http://www.datamanipulation.net
--
"Griff" <Howling@.The.Moon> wrote in message
news:OS5efhMqFHA.1556@.TK2MSFTNGP12.phx.gbl...
> I have an application that needs to check users' log on credentials from a
> web front end.
> The web front end passes the user name and password to a stored procedure
> and, if the stored procedure finds someone with those credentials then it
> returns the user's ID.
> Trouble is that SQLServer has been installed to be case insensitive, so
> "password" = "PASSWORD"
> Is there anything that I can do in the stored procedure that can make the
> select statement case sensitive for this particular query?
> Thanks
> Griff
>|||Try to convert them to a binary and then compare...
Marcel van Eijkel
( www.vaneijkel.com )sql

Tuesday, March 20, 2012

case and order by problem?

Is there a problem with the case and order by when you attempt to order by a
column that has been labeled?
example (with assist from user MySqlServer, thanks you)
CREATE TABLE tenbeat (
tenbeatcol1 int,
tenbeatcol2 int
)
INSERT INTO tenbeat VALUES(3,4)
INSERT INTO tenbeat VALUES(1,2)
INSERT INTO tenbeat VALUES(0,0)
/* this works */
select *,
case tenbeatcol1 when 1 then 'yes' else 'no' end as yesno
from tenbeat
order by yesno
/* this gives me an invalid column on the order by */
declare @.ord as varchar(10)
select @.ord = 'ok'
select *,
case tenbeatcol1 when 1 then 'yes' else 'no' end as yesno
from tenbeat
order by
case @.ord
When 'ok' Then yesno
Else tenbeatcol1
end
drop table tenbeat
thanks (any ideas?)
kes
--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kesORDER BY allows you to specify
1. col_name
2. col_alias
3. col_position
It is the CASE statement that is generating the error. CASE does not work
with col_alias.. therefore gving error
Rakesh
"WebBuilder451" wrote:

> Is there a problem with the case and order by when you attempt to order by
a
> column that has been labeled?
> example (with assist from user MySqlServer, thanks you)
> CREATE TABLE tenbeat (
> tenbeatcol1 int,
> tenbeatcol2 int
> )
> INSERT INTO tenbeat VALUES(3,4)
> INSERT INTO tenbeat VALUES(1,2)
> INSERT INTO tenbeat VALUES(0,0)
> /* this works */
> select *,
> case tenbeatcol1 when 1 then 'yes' else 'no' end as yesno
> from tenbeat
> order by yesno
> /* this gives me an invalid column on the order by */
> declare @.ord as varchar(10)
> select @.ord = 'ok'
> select *,
> case tenbeatcol1 when 1 then 'yes' else 'no' end as yesno
> from tenbeat
> order by
> case @.ord
> When 'ok' Then yesno
> Else tenbeatcol1
> end
> drop table tenbeat
> thanks (any ideas?)
> kes
> --
> thanks (as always)
> some day i''m gona pay this forum back for all the help i''m getting
> kes|||You can reference an alias in the "order by" clause, but not from an
expression, the references should be straight. You will have to use the
expression used in the column list of the "select" statement.
-- works
select 1 as c1
order by c1
-- does not work
select 1 as c1
order by case when c1 = 1 then 1 else 0 end

> case tenbeatcol1 when 1 then 'yes' else 'no' end as yesno
> from tenbeat
> order by
> case @.ord
> When 'ok' Then yesno
> Else tenbeatcol1
...
order by
case @.ord
When 'ok' Then case tenbeatcol1 when 1 then 'yes' else 'no' end
Else tenbeatcol1
end
but now you will have another problem, and this is that the result's
datatype of a case expression is equal to the one with higher precedence in
it. In your case, column [tenbeatcol1] is "int" and the inner "case"
expression yield a "varchar", when sql server try to convert values 'yes' or
'no' to "int", then an error will araise.
Example:
use northwind
go
declare @.c varchar(15)
set @.c = 'yes'
select
case when c1 = 1 then 'yes' else 'no' end
from
(
select 1 as c1
union all
select 2 as c1
) as t1
order by
case
when @.c = 'yes' then case when c1 = 1 then 'yes' else 'no' end
else c1
end
go
you have to use datatypes and / or values that can be implicitly converted
in order to sql server promote then or you have to convert them explicitly.
declare @.c varchar(15)
set @.c = 'yes'
select
case when c1 = 1 then 'yes' else 'no' end
from
(
select 1 as c1
union all
select 2 as c1
) as t1
order by
case
when @.c = 'yes' then case when c1 = 1 then 'yes' else 'no' end
else ltrim(c1) <--
end
go
How do I use a variable in an ORDER BY clause?
http://www.aspfaq.com/show.asp?id=2501
AMB
"WebBuilder451" wrote:

> Is there a problem with the case and order by when you attempt to order by
a
> column that has been labeled?
> example (with assist from user MySqlServer, thanks you)
> CREATE TABLE tenbeat (
> tenbeatcol1 int,
> tenbeatcol2 int
> )
> INSERT INTO tenbeat VALUES(3,4)
> INSERT INTO tenbeat VALUES(1,2)
> INSERT INTO tenbeat VALUES(0,0)
> /* this works */
> select *,
> case tenbeatcol1 when 1 then 'yes' else 'no' end as yesno
> from tenbeat
> order by yesno
> /* this gives me an invalid column on the order by */
> declare @.ord as varchar(10)
> select @.ord = 'ok'
> select *,
> case tenbeatcol1 when 1 then 'yes' else 'no' end as yesno
> from tenbeat
> order by
> case @.ord
> When 'ok' Then yesno
> Else tenbeatcol1
> end
> drop table tenbeat
> thanks (any ideas?)
> kes
> --
> thanks (as always)
> some day i''m gona pay this forum back for all the help i''m getting
> kes|||try this:
declare @.ord as varchar(10)
select @.ord = 'ok'
Select * from
(select tenbeatcol1,tenbeatcol2,
case tenbeatcol1
when 1
then 'yes'
else 'no'
end 'yesno'
from tenbeat) t
order by case
When @.ord = 'ok'
Then yesno
Else convert(varchar,tenbeatcol1)
end
"WebBuilder451" <WebBuilder451@.discussions.microsoft.com> wrote in message
news:14F08262-2096-4A4D-825A-23F6EE8F2682@.microsoft.com...
> Is there a problem with the case and order by when you attempt to order by
> a
> column that has been labeled?
> example (with assist from user MySqlServer, thanks you)
> CREATE TABLE tenbeat (
> tenbeatcol1 int,
> tenbeatcol2 int
> )
> INSERT INTO tenbeat VALUES(3,4)
> INSERT INTO tenbeat VALUES(1,2)
> INSERT INTO tenbeat VALUES(0,0)
> /* this works */
> select *,
> case tenbeatcol1 when 1 then 'yes' else 'no' end as yesno
> from tenbeat
> order by yesno
> /* this gives me an invalid column on the order by */
> declare @.ord as varchar(10)
> select @.ord = 'ok'
> select *,
> case tenbeatcol1 when 1 then 'yes' else 'no' end as yesno
> from tenbeat
> order by
> case @.ord
> When 'ok' Then yesno
> Else tenbeatcol1
> end
> drop table tenbeat
> thanks (any ideas?)
> kes
> --
> thanks (as always)
> some day i''m gona pay this forum back for all the help i''m getting
> kes|||could the posting below work w/o a big performance hit?
[Select * from
(select tenbeatcol1,tenbeatcol2,
case tenbeatcol1
when 1
then 'yes'
else 'no'
end 'yesno'
from tenbeat) t
order by case
When @.ord = 'ok'
Then yesno
Else convert(varchar,tenbeatcol1)
end
]
thanks
kes
--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes
"Alejandro Mesa" wrote:
> You can reference an alias in the "order by" clause, but not from an
> expression, the references should be straight. You will have to use the
> expression used in the column list of the "select" statement.
> -- works
> select 1 as c1
> order by c1
> -- does not work
> select 1 as c1
> order by case when c1 = 1 then 1 else 0 end
>
> ...
> order by
> case @.ord
> When 'ok' Then case tenbeatcol1 when 1 then 'yes' else 'no' end
> Else tenbeatcol1
> end
> but now you will have another problem, and this is that the result's
> datatype of a case expression is equal to the one with higher precedence i
n
> it. In your case, column [tenbeatcol1] is "int" and the inner "case"
> expression yield a "varchar", when sql server try to convert values 'yes'
or
> 'no' to "int", then an error will araise.
> Example:
> use northwind
> go
> declare @.c varchar(15)
> set @.c = 'yes'
> select
> case when c1 = 1 then 'yes' else 'no' end
> from
> (
> select 1 as c1
> union all
> select 2 as c1
> ) as t1
> order by
> case
> when @.c = 'yes' then case when c1 = 1 then 'yes' else 'no' end
> else c1
> end
> go
> you have to use datatypes and / or values that can be implicitly converted
> in order to sql server promote then or you have to convert them explicitly
.
> declare @.c varchar(15)
> set @.c = 'yes'
> select
> case when c1 = 1 then 'yes' else 'no' end
> from
> (
> select 1 as c1
> union all
> select 2 as c1
> ) as t1
> order by
> case
> when @.c = 'yes' then case when c1 = 1 then 'yes' else 'no' end
> else ltrim(c1) <--
> end
> go
> How do I use a variable in an ORDER BY clause?
> http://www.aspfaq.com/show.asp?id=2501
>
> AMB
> "WebBuilder451" wrote:
>|||thanks that's an alternative, i've asked someone else the same question, but
will this cause a performance hit?
this'd be great if it didn't
thanks
kes
--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes
"Pradeep Kutty" wrote:

> try this:
> declare @.ord as varchar(10)
> select @.ord = 'ok'
> Select * from
> (select tenbeatcol1,tenbeatcol2,
> case tenbeatcol1
> when 1
> then 'yes'
> else 'no'
> end 'yesno'
> from tenbeat) t
> order by case
> When @.ord = 'ok'
> Then yesno
> Else convert(varchar,tenbeatcol1)
> end
> "WebBuilder451" <WebBuilder451@.discussions.microsoft.com> wrote in message
> news:14F08262-2096-4A4D-825A-23F6EE8F2682@.microsoft.com...
>
>|||depends on the data and how u index the table...
see the execution plan and profiler metrics...
if its bad try union all...
Prad
"WebBuilder451" <WebBuilder451@.discussions.microsoft.com> wrote in message
news:56A0A748-8E0D-4F28-A52A-40C500CB5090@.microsoft.com...
> thanks that's an alternative, i've asked someone else the same question,
> but
> will this cause a performance hit?
> this'd be great if it didn't
> thanks
> kes
> --
> thanks (as always)
> some day i''m gona pay this forum back for all the help i''m getting
> kes
>
> "Pradeep Kutty" wrote:
>|||so far it's ok, no difference, It's pulling from 5 tables/w total 1,000,000+
records, returning 3,500 rows in about 1 sec for the worst case so it's ok.
thanks
kes
--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes
"Pradeep Kutty" wrote:

> depends on the data and how u index the table...
> see the execution plan and profiler metrics...
> if its bad try union all...
> Prad
> "WebBuilder451" <WebBuilder451@.discussions.microsoft.com> wrote in message
> news:56A0A748-8E0D-4F28-A52A-40C500CB5090@.microsoft.com...
>
>|||Can you do the sorting in the client application?
AMB
"WebBuilder451" wrote:
> could the posting below work w/o a big performance hit?
> [Select * from
> (select tenbeatcol1,tenbeatcol2,
> case tenbeatcol1
> when 1
> then 'yes'
> else 'no'
> end 'yesno'
> from tenbeat) t
> order by case
> When @.ord = 'ok'
> Then yesno
> Else convert(varchar,tenbeatcol1)
> end
> ]
> thanks
> kes
> --
> thanks (as always)
> some day i''m gona pay this forum back for all the help i''m getting
> kes
>
> "Alejandro Mesa" wrote:
>|||I can do a query of queries in the app language (it's cold fusion) This like
making a dataview on a dataset and sorting in DOT.NET. Although it is faster
than the dot.net dataview (sorry to blaspheme) it'd still be slower than the
suggested solution. In the end it seems that real speed all comes down to th
e
sql and the dbdesign.
thanks
kes
--
thanks (as always)
some day i''m gona pay this forum back for all the help i''m getting
kes
"Alejandro Mesa" wrote:
> Can you do the sorting in the client application?
>
> AMB
> "WebBuilder451" wrote:
>

Monday, March 19, 2012

Cascading(?) Parameters Help

I have 2 parameters that are of type string. The user can enter anything they want in them. The third parameter is query based and uses the first 2 parameters to get a list of people. Is there a way I can prevent the third parameter from propigating until the first 2 are both filled in? The first 2 cannot be drop downs however, they are used in a wild card fashion.

Thanks!

Yes. Set the default on the text boxes to NULL.

Then it shouldnt try to populate until both are not null.

I just created a test report and it did not populate until both names were entered.

BobP

|||

In RS2005? I just did the same thing, and the 3rd Parameter became available after I entered something in the 1st parameter (no values because the query is where firstname = @.param1 and lastname = @.param2). However, the real query is using firstname LIKE @.param1 and lastname LIKE param2 and thus populates the list as soon as I enter the first name. Which is confusing because param2 is empty. Any ideas?

|||

Ah.. I see. I had the 'Allow blank value' selected. However, not pretty, it works.

|||

So it IS working for you, right?

BobP

|||Yes.. thanks.

Cascading Parameters Unreliable

I find that cascading parameters work intermittently. In addition, a
report with a drop down list will sometimes attempt to execute before
the user has made a selection.make sure you have the parameters in the proper order for cascading to work
properly. i.e. country parm first in your parameter list, state parameter
second, city parameter third... all the cascading parameters have to be
ahead of your other non-cascading parameters. to ensure the report will not
execute before a user selects parms... just leave 1 parm without default
value.
"mjhillman@.msn.com" wrote:
> I find that cascading parameters work intermittently. In addition, a
> report with a drop down list will sometimes attempt to execute before
> the user has made a selection.
>|||I am calling two stored procedures that take the same parameter. I
only have one parameter in the parameter list. Does this suggestion
apply to this scenario as well? Do I have to modify the SP to use a
different parameter name? (I did not write the SPs I am just executing
reports against an existing WMS.). Thanks.

Cascading parameters problem : First parameter is textbox

Hi,
I am using cascading parameters in my report. The first paramter is a
servername which user types in a TextBox. The second parameter is
populated based on the first parameter.
The problem is secord paramter drop down list doesn't get populated
unless I press "View Report" button in the preview mode.
Is there any way to populate second parameter (drop downlist) as user
finished typing the first parameter (TextBox)
please help,
regards,
SAchinUser needs to press "Tab" key to populate and need not press "view report"
Amarnath
"sachin laddha" wrote:
> Hi,
> I am using cascading parameters in my report. The first paramter is a
> servername which user types in a TextBox. The second parameter is
> populated based on the first parameter.
> The problem is secord paramter drop down list doesn't get populated
> unless I press "View Report" button in the preview mode.
> Is there any way to populate second parameter (drop downlist) as user
> finished typing the first parameter (TextBox)
> please help,
> regards,
> SAchin
>

Cascading parameters and multi-value parameters

I have a dataset where a user can select yard, well, or both yard and
well. (basically a parameter with yard and well as values, but I made
it a multi-value parameter so they can choose both if needed). The
problem I am having is that the next paramater is based off of the
first one. If yard is selected I run a certain query, if well is
selected a run a different query. How can I say if all is selected
join both the yard and well query to get the data results. Any ideas?
thanks in advance.Use an If in the datatab and use In ('Yard', 'Well') in your query.
Amarnath
"aggiechick717" wrote:
> I have a dataset where a user can select yard, well, or both yard and
> well. (basically a parameter with yard and well as values, but I made
> it a multi-value parameter so they can choose both if needed). The
> problem I am having is that the next paramater is based off of the
> first one. If yard is selected I run a certain query, if well is
> selected a run a different query. How can I say if all is selected
> join both the yard and well query to get the data results. Any ideas?
> thanks in advance.
>

Wednesday, March 7, 2012

carriage return problem..

While retrieving user input from an input control, eg: multi-line textbox, and inserting it into the database, the carriage return or the 'Enter' key is not getting inserting into the database.. instead it inserts a quad ( square ) in the database.. also the text typed after the 'Enter' key is not getting inserted into the database.. please help.The carriage returnis getting inserted. The square box confirms that. When rendering it to a web page, you need to replace the carriage returns with their html equivalent - "<br />"|||I'm having the same problem, how would this be accomplished using VB?|||

VB.Net
<%# Eval("MyValue").ToString().Replace(vbcrlf,"<br />") %>

C#
<%# Eval("MyValue").ToString().Replace("\r","<br />") %>

|||

Thanks!

It works great!

I was also able to get it going with the following a few minutes ago:

<%# Eval("MyValue").Replace(Environment.NewLine, "<br />") %>

Which method do you recommend or are they both good?

|||

With the .NET framework, there are approximately 63 ways to skin most particular cats. The difference between them is most often negligible, and you should use whatever you prefer so long as your page load doesn't appear to be adversely affected. Occasionally you will get a guru tell you to use one option rather than another, because it shaves nanoseconds off the operation, and they will have benchmark tests to prove it. Personally, I think life is too short. I usually use the option that requires less typing, unless I am informed of a convincing reason to use another.

Environment.NewLine has the benefit that it can be used regardless of page language, so I shall use it in future when I answer this question without knowing the language the poster is using. Quite simply, it meets my desire to do less typing.Big Smile

Saturday, February 25, 2012

capturing reportviewer parameters

Hi Guys
I have an application which consists of a navigation bar and a frame.
When a user selects a hyperlink on the navigation bar that particular
report is displayed in the frame. Now these reports contains links
through which the user can jump to some other report which is not
present in the navigation bar. Now when the user clicks any other link
on the navigation bar the new report is starting up using the default
parameters set for that report. But i dont want this to happen. The
report viewer should take the latest parameters set in the report
viewer and pass them to the new report that will be generated when the
user clicks on the navigation bar. Can any body help with this aspect.
it is blowing up my brains. dont even know that whether this is
possible.
Also can we somehow get the url of the report being displayed in the
report viewer." i know that report viewer is an iframe which uses url
access beneath it to access the reports." Only the first report server
url is encoded in the application. But when the user navigated to some
other report through the links in reports how do i get access to that
particular report url .
any help will really be great. I am wondering is it really possible to
do the stuff i just mentioned above. Any tips on this will really save
me a lot of time.
Thanks in advance.../......
Passxunlimitedyou have to add some code to save the parameters and reuse them when you
open a new report.
you have to intercept some events (from the reportviewer control) to
retrieve the parameters when the first report is refreshed with new
parameters, save the values into a the session, in the page load event if
you open a new report change the values of the parameters of these reports
regarding what you have saved before.
its not complicated, the API is easy to use to do this.
"Passx" <passxunlimited@.gmail.com> wrote in message
news:1167432103.071025.84650@.a3g2000cwd.googlegroups.com...
> Hi Guys
> I have an application which consists of a navigation bar and a frame.
> When a user selects a hyperlink on the navigation bar that particular
> report is displayed in the frame. Now these reports contains links
> through which the user can jump to some other report which is not
> present in the navigation bar. Now when the user clicks any other link
> on the navigation bar the new report is starting up using the default
> parameters set for that report. But i dont want this to happen. The
> report viewer should take the latest parameters set in the report
> viewer and pass them to the new report that will be generated when the
> user clicks on the navigation bar. Can any body help with this aspect.
> it is blowing up my brains. dont even know that whether this is
> possible.
> Also can we somehow get the url of the report being displayed in the
> report viewer." i know that report viewer is an iframe which uses url
> access beneath it to access the reports." Only the first report server
> url is encoded in the application. But when the user navigated to some
> other report through the links in reports how do i get access to that
> particular report url .
> any help will really be great. I am wondering is it really possible to
> do the stuff i just mentioned above. Any tips on this will really save
> me a lot of time.
> Thanks in advance.../......
> Passxunlimited
>|||i was trying to do exactly the same thing . But could not find any
events associated with report viewer wherein i can catch the parameter
values or session state. Any idea or resources regarding this.
thanks
passx
Jeje wrote:
> you have to add some code to save the parameters and reuse them when you
> open a new report.
> you have to intercept some events (from the reportviewer control) to
> retrieve the parameters when the first report is refreshed with new
> parameters, save the values into a the session, in the page load event if
> you open a new report change the values of the parameters of these reports
> regarding what you have saved before.
> its not complicated, the API is easy to use to do this.
>
> "Passx" <passxunlimited@.gmail.com> wrote in message
> news:1167432103.071025.84650@.a3g2000cwd.googlegroups.com...
> > Hi Guys
> >
> > I have an application which consists of a navigation bar and a frame.
> > When a user selects a hyperlink on the navigation bar that particular
> > report is displayed in the frame. Now these reports contains links
> > through which the user can jump to some other report which is not
> > present in the navigation bar. Now when the user clicks any other link
> > on the navigation bar the new report is starting up using the default
> > parameters set for that report. But i dont want this to happen. The
> > report viewer should take the latest parameters set in the report
> > viewer and pass them to the new report that will be generated when the
> > user clicks on the navigation bar. Can any body help with this aspect.
> > it is blowing up my brains. dont even know that whether this is
> > possible.
> >
> > Also can we somehow get the url of the report being displayed in the
> > report viewer." i know that report viewer is an iframe which uses url
> > access beneath it to access the reports." Only the first report server
> > url is encoded in the application. But when the user navigated to some
> > other report through the links in reports how do i get access to that
> > particular report url .
> >
> > any help will really be great. I am wondering is it really possible to
> > do the stuff i just mentioned above. Any tips on this will really save
> > me a lot of time.
> >
> > Thanks in advance.../......
> > Passxunlimited
> >|||try the onunload event or any event after the rendering step.
"Passx" <passxunlimited@.gmail.com> wrote in message
news:1167942475.840285.10930@.51g2000cwl.googlegroups.com...
>i was trying to do exactly the same thing . But could not find any
> events associated with report viewer wherein i can catch the parameter
> values or session state. Any idea or resources regarding this.
>
> thanks
> passx
> Jeje wrote:
>> you have to add some code to save the parameters and reuse them when you
>> open a new report.
>> you have to intercept some events (from the reportviewer control) to
>> retrieve the parameters when the first report is refreshed with new
>> parameters, save the values into a the session, in the page load event if
>> you open a new report change the values of the parameters of these
>> reports
>> regarding what you have saved before.
>> its not complicated, the API is easy to use to do this.
>>
>> "Passx" <passxunlimited@.gmail.com> wrote in message
>> news:1167432103.071025.84650@.a3g2000cwd.googlegroups.com...
>> > Hi Guys
>> >
>> > I have an application which consists of a navigation bar and a frame.
>> > When a user selects a hyperlink on the navigation bar that particular
>> > report is displayed in the frame. Now these reports contains links
>> > through which the user can jump to some other report which is not
>> > present in the navigation bar. Now when the user clicks any other link
>> > on the navigation bar the new report is starting up using the default
>> > parameters set for that report. But i dont want this to happen. The
>> > report viewer should take the latest parameters set in the report
>> > viewer and pass them to the new report that will be generated when the
>> > user clicks on the navigation bar. Can any body help with this aspect.
>> > it is blowing up my brains. dont even know that whether this is
>> > possible.
>> >
>> > Also can we somehow get the url of the report being displayed in the
>> > report viewer." i know that report viewer is an iframe which uses url
>> > access beneath it to access the reports." Only the first report server
>> > url is encoded in the application. But when the user navigated to some
>> > other report through the links in reports how do i get access to that
>> > particular report url .
>> >
>> > any help will really be great. I am wondering is it really possible to
>> > do the stuff i just mentioned above. Any tips on this will really save
>> > me a lot of time.
>> >
>> > Thanks in advance.../......
>> > Passxunlimited
>> >
>

Capturing operations and tSQL executed under a user account

All,
I am looking for a way to capture all of the SQL code executed against a
database by a specific user.
Currently, a SQL 2005 database is being maintained by a third party that
connects remotely and does occasional "maintenance." The client would like
to bring this operation in house and is looking for a way to capture these
activities so that they can be documented.
The accuracy of this is essential so we are looking for a way to do a direct
capture.
Suggestions?
Ryan Hanisco
MCSE, MCTS: SQL 2005, Project+
Chicago, IL
Remember: Marking helpful answers helps everyone find the info they need
quickly.
On Jun 7, 4:06 pm, Ryan Hanisco
<RyanHani...@.discussions.microsoft.com> wrote:
> All,
> I am looking for a way to capture all of the SQL code executed against a
> database by a specific user.
> Currently, a SQL 2005 database is being maintained by a third party that
> connects remotely and does occasional "maintenance." The client would like
> to bring this operation in house and is looking for a way to capture these
> activities so that they can be documented.
> The accuracy of this is essential so we are looking for a way to do a direct
> capture.
> Suggestions?
The easy way is to use Profiler. (That's what they called it in SQL
2000, it's undoubtedly there in SQL 2005 but possibly under a new
name.)
If you have to do it the hard way, look at the sp_trace stored
procedure.
|||Ryan Hanisco (RyanHanisco@.discussions.microsoft.com) writes:
> I am looking for a way to capture all of the SQL code executed against a
> database by a specific user.
> Currently, a SQL 2005 database is being maintained by a third party that
> connects remotely and does occasional "maintenance." The client would
> like to bring this operation in house and is looking for a way to
> capture these activities so that they can be documented.
> The accuracy of this is essential so we are looking for a way to do a
> direct capture.
This is precisely what SQL Profiler is good for. Or a server side trace,
if you want to reduce the load.
Although, this appears to me a somewhat funny thing to document procedures.
It sounds more like eavesdropping to me.n
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

Capturing ODBC user name at runtime

Hi:
We are using SRS to report from a DB2 database running on AS400's. It is
working very well.
Pushing ahead, we want to capture information on when certain reports
(actually letters) are generated. The reports prompt for login credentials
at run time. These DB2 database credentials are passed to the database
server and the report returns the data just fine. Works great right out of
the box.
What we would like to do is capture the user name that is passed to the
database. This is not the Windows AD username that can be obtained by the
global field
User!UserID, but the DB2 specific user name that is passed by the ODBC
connection.
Can this be captured at runtime? We have reviewed the RS object model and
haven't found what we are looking for. Are we barking up the wrong tree?
Thanks in advance.
Bruce.
swgAre the credentials parameters?
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"bwschiek@.hotmail.com" <bwschiekhotmailcom@.discussions.microsoft.com> wrote
in message news:CC286D82-B3E9-48F4-AD5A-ACAB49A19C8B@.microsoft.com...
> Hi:
> We are using SRS to report from a DB2 database running on AS400's. It is
> working very well.
> Pushing ahead, we want to capture information on when certain reports
> (actually letters) are generated. The reports prompt for login
> credentials
> at run time. These DB2 database credentials are passed to the database
> server and the report returns the data just fine. Works great right out
> of
> the box.
> What we would like to do is capture the user name that is passed to the
> database. This is not the Windows AD username that can be obtained by the
> global field
> User!UserID, but the DB2 specific user name that is passed by the ODBC
> connection.
> Can this be captured at runtime? We have reviewed the RS object model and
> haven't found what we are looking for. Are we barking up the wrong tree?
> Thanks in advance.
> Bruce.
> swg|||Hi:
They are not parameters in the sense that they are built into the report as
parameters.
Instead of saving credentials securely on the report server, I selected the
"The credentials supplied by the user running the report." under the "Connect
Using:" portion of the datasource Properties page.
It is that username that the user enters at runtime that I need to capture.
Thanks.
Bruce.
"Bruce L-C [MVP]" wrote:
> Are the credentials parameters?
>
> --
> Bruce Loehle-Conger
> MVP SQL Server Reporting Services
> "bwschiek@.hotmail.com" <bwschiekhotmailcom@.discussions.microsoft.com> wrote
> in message news:CC286D82-B3E9-48F4-AD5A-ACAB49A19C8B@.microsoft.com...
> > Hi:
> >
> > We are using SRS to report from a DB2 database running on AS400's. It is
> > working very well.
> >
> > Pushing ahead, we want to capture information on when certain reports
> > (actually letters) are generated. The reports prompt for login
> > credentials
> > at run time. These DB2 database credentials are passed to the database
> > server and the report returns the data just fine. Works great right out
> > of
> > the box.
> >
> > What we would like to do is capture the user name that is passed to the
> > database. This is not the Windows AD username that can be obtained by the
> > global field
> > User!UserID, but the DB2 specific user name that is passed by the ODBC
> > connection.
> >
> > Can this be captured at runtime? We have reviewed the RS object model and
> > haven't found what we are looking for. Are we barking up the wrong tree?
> >
> > Thanks in advance.
> >
> > Bruce.
> >
> > swg
>
>|||Oh, I see. Sorry. I am not aware of a way to get this via built in
functionality but how about this. It depends on your database but SQL Server
has a function that returns the user:
SELECT 'The current user is: '+ convert(char(30), CURRENT_USER)
If your database has something similar then have a second dataset that uses
the same data source and get the information that way.-- Bruce Loehle-Conger
MVP SQL Server Reporting Services
"bwschiek@.hotmail.com" <bwschiekhotmailcom@.discussions.microsoft.com> wrote
in message news:FB08FB96-06B5-4E39-A9DA-4929CFC3629E@.microsoft.com...
> Hi:
> They are not parameters in the sense that they are built into the report
> as
> parameters.
> Instead of saving credentials securely on the report server, I selected
> the
> "The credentials supplied by the user running the report." under the
> "Connect
> Using:" portion of the datasource Properties page.
> It is that username that the user enters at runtime that I need to
> capture.
> Thanks.
> Bruce.
> "Bruce L-C [MVP]" wrote:
>> Are the credentials parameters?
>>
>> --
>> Bruce Loehle-Conger
>> MVP SQL Server Reporting Services
>> "bwschiek@.hotmail.com" <bwschiekhotmailcom@.discussions.microsoft.com>
>> wrote
>> in message news:CC286D82-B3E9-48F4-AD5A-ACAB49A19C8B@.microsoft.com...
>> > Hi:
>> >
>> > We are using SRS to report from a DB2 database running on AS400's. It
>> > is
>> > working very well.
>> >
>> > Pushing ahead, we want to capture information on when certain reports
>> > (actually letters) are generated. The reports prompt for login
>> > credentials
>> > at run time. These DB2 database credentials are passed to the database
>> > server and the report returns the data just fine. Works great right
>> > out
>> > of
>> > the box.
>> >
>> > What we would like to do is capture the user name that is passed to the
>> > database. This is not the Windows AD username that can be obtained by
>> > the
>> > global field
>> > User!UserID, but the DB2 specific user name that is passed by the ODBC
>> > connection.
>> >
>> > Can this be captured at runtime? We have reviewed the RS object model
>> > and
>> > haven't found what we are looking for. Are we barking up the wrong
>> > tree?
>> >
>> > Thanks in advance.
>> >
>> > Bruce.
>> >
>> > swg
>>

Friday, February 24, 2012

Capture user that calls sp_start_job

I have 10 users assigned to SQLAgentOperatorRole. I want to track which of the users calls sp_start_job. I am using Windows authentication. How can I capture the identity of the user that calls sp_start_job?

I want to do something like "INSERT INTO tbJobHistory(JobName, RunDate, User)"

No, unless you run profiler or encapsulate the procedure callo in your own procedure, there is no way to this.

Jens K. Suessmeyer

http://www.sqlserver2005.de

Capture NT User ID

Access front-end, SQL Server 2005 backend.

I have users connected to SQL Server via a Microsoft Access user-
interface.
Connection is via NT login.

I want to log users' activities to the database with their userid.

How can I capture their NT User ID (via VBA in Access)?

Thanks,
BubblesYou could create a view in SQL Server, I guess, like:

CREATE VIEW dbo.NTUsername
AS
SELECT [username] = SUSER_SNAME();

Now VBA should be able to query from that view in SQL Server just like it
would any other table or view...

--
Aaron Bertrand
SQL Server MVP
http://www.sqlblog.com/
http://www.aspfaq.com/5006
"bubbles" <bubbles.one@.hotmail.comwrote in message
news:1175737278.694527.78540@.q75g2000hsh.googlegro ups.com...

Quote:

Originally Posted by

Access front-end, SQL Server 2005 backend.
>
I have users connected to SQL Server via a Microsoft Access user-
interface.
Connection is via NT login.
>
I want to log users' activities to the database with their userid.
>
How can I capture their NT User ID (via VBA in Access)?
>
Thanks,
Bubbles
>