Hi,
I have a .NET application that connects to a SQL 2000 database using
trusted security. It eventually calls a stored procedure that receives
3 parameters - nothing special.
If I simply change the connection string to use a valid Userid and
Password it still connects to the DB w/o problems but when it executes
the SP I get the following:
System.Data.SqlClient.SqlException: Invalid length parameter passed to
the substring function.
I change nothing but the login. Same store procedure, same parameters.
Any ideas? 6 2683
Check the proc (or invoked trigger) to see SUSER_SNAME() is being parsed
into separate domain/account components. The code may fail with a standard
SQL Security connection because a '\' is assumed to be present.
--
Happy Holidays
Dan Guzman
SQL Server MVP
"ZRexRider" <je****@ptd.net> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com... Hi,
I have a .NET application that connects to a SQL 2000 database using trusted security. It eventually calls a stored procedure that receives 3 parameters - nothing special.
If I simply change the connection string to use a valid Userid and Password it still connects to the DB w/o problems but when it executes the SP I get the following:
System.Data.SqlClient.SqlException: Invalid length parameter passed to the substring function.
I change nothing but the login. Same store procedure, same parameters.
Any ideas?
ZRexRider (je****@ptd.net) writes: I have a .NET application that connects to a SQL 2000 database using trusted security. It eventually calls a stored procedure that receives 3 parameters - nothing special.
If I simply change the connection string to use a valid Userid and Password it still connects to the DB w/o problems but when it executes the SP I get the following:
System.Data.SqlClient.SqlException: Invalid length parameter passed to the substring function.
I change nothing but the login. Same store procedure, same parameters.
Any ideas?
A Christmas quiz? Maybe you should try rec.games.trivia in such case.
If this is not meant to be a quiz, please show us the code you are
having problem with, both the ADO .Net code and the stored procedure.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se
Books Online for SQL Server 2005 at http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinf...ons/books.mspx
Dan you nailed it - SUSER_SNAME() in my trigger blows up because there
isn't a '\' and I didn't code for it.
Happy Holidays to you as well!
Dan Guzman wrote: Check the proc (or invoked trigger) to see SUSER_SNAME() is being parsed into separate domain/account components. The code may fail with a standard SQL Security connection because a '\' is assumed to be present.
-- Happy Holidays
Dan Guzman SQL Server MVP
"ZRexRider" <je****@ptd.net> wrote in message news:11**********************@g44g2000cwa.googlegr oups.com... Hi,
I have a .NET application that connects to a SQL 2000 database using trusted security. It eventually calls a stored procedure that receives 3 parameters - nothing special.
If I simply change the connection string to use a valid Userid and Password it still connects to the DB w/o problems but when it executes the SP I get the following:
System.Data.SqlClient.SqlException: Invalid length parameter passed to the substring function.
I change nothing but the login. Same store procedure, same parameters.
Any ideas?
How can I make the following trigger work on both Trusted and
non-trusted connections?
CREATE TRIGGER trIU_tblTest
ON dbo.tblTest
FOR INSERT, UPDATE AS
BEGIN
DECLARE @strUserName VARCHAR(20)
SET NOCOUNT ON
SET ANSI_WARNINGS OFF
-- only want the userlogon name portion
SELECT @strUserName =
right(suser_sname(),CHARINDEX('\',REVERSE(suser_sn ame()))-1)
UPDATE
tbTest
SET
UpdateUserName=@strUserName,
UpdateDate=GETDATE()
WHERE
tblTest.ID IN (SELECT inserted.ID FROM inserted)
SET NOCOUNT OFF
END
ZRexRider (je****@ptd.net) writes: How can I make the following trigger work on both Trusted and non-trusted connections?
CREATE TRIGGER trIU_tblTest ON dbo.tblTest FOR INSERT, UPDATE AS BEGIN DECLARE @strUserName VARCHAR(20)
SET NOCOUNT ON SET ANSI_WARNINGS OFF -- only want the userlogon name portion SELECT @strUserName = right(suser_sname(),CHARINDEX('\',REVERSE(suser_sn ame()))-1)
DECLARE @username nvarchar(256)
SELECT @username = SYSTEM_USER
IF charindex('\', @username) > 0
SELECT @username = substr(@username, charindex('\', @username) + 1,
len(@username)
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se
Books Online for SQL Server 2005 at http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinf...ons/books.mspx
Thank You Erland - Merry Christmas to you! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Nashat Wanly |
last post by:
HOW TO: Call a Parameterized Stored Procedure by Using ADO.NET and
Visual C# .NET
View products that this article applies to.
This article was previously published under Q310070
For a Microsoft...
|
by: Martin Feuersteiner |
last post by:
Dear Group
I have found that table A had SELECT permissions for 'Public' but not table
B.
Giving 'Public' SELECT permissions on table B did the trick.
HOWEVER, I don't want anyone to be able...
|
by: Brad H McCollum |
last post by:
I'm writing an application using VB 6.0 as the front-end GUI, and the
MSDE version of SQL Server as the back-end (it's a program for a
really small # of users --- less then 3-4).
I'm trying to...
|
by: Josh Strickland |
last post by:
I am attempting to create an Access database which uses forms to enter
data. The issue I am having is returning the query results from the
Stored Procedure back in to the Access Form.
...
|
by: Wojciech Wendrychowicz |
last post by:
Hello to All,
I'm trying to retrieve records from AS/400 in an VBA application.
So, I've made an RPG program, then a stored procedure wchich calls that RPG
program, and finally some VBA code to...
|
by: Mike Hutton |
last post by:
I have a rather odd problem.
I have a SP which uses temp. tables along the way, and then returns a
table of results:
CREATE PROCEDURE dbo.usp_myproc(
@pNameList VARCHAR(6000)
)
AS
|
by: John |
last post by:
Hi
When developing vb.bet winform apps bound to sql server datasource, is it
preferable to use SELECTs or stored procedure to read and write data from/to
SQL Server? Why?
Thanks
Regards
|
by: Siv |
last post by:
Hi,
I have a stored procedure that I want to execute and then wait in a loop
showing a timer whilst it completes and then carry on once I get
notification that it has completed. The main reason...
|
by: nishi57 |
last post by:
I hope I can get some help regarding this issue, which has been going
on for a while. I have a desktop user who is having problem running
"Stored Procedures". The DB2 Connect application works fine...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |