Showing posts with label program. Show all posts
Showing posts with label program. Show all posts

Wednesday, March 21, 2012

Login failed for user

Hi All
I am using MSDE2K and an application written in VB6
After installing MSDE and my program on to a new computer I am having
strange problems when saving data which I didn't get on the old computer
My connection string is...
cn.ConnectionString = "Provider=SQLOLEDB;Persist Security Info=False;User
ID=Tramcars;Password=ga711bm;Initial Catalog=Tramcars;Data Source=(local)"
(User ID Tramcars exists in MSDE and is included in the db_owner role)
This connects me OK and allows me to enter new data and save
On creating a new entry and attempting to save again I get the message
'Login failed for user Tramcars'
If I set 'Persist Security Info=True' in the connection string, all works
fine
I am completely lost
Any ideas?
Regards
Steve
hi Steve,
steve wrote:
> Hi All
> I am using MSDE2K and an application written in VB6
> After installing MSDE and my program on to a new computer I am having
> strange problems when saving data which I didn't get on the old
> computer
> My connection string is...
> cn.ConnectionString = "Provider=SQLOLEDB;Persist Security
> Info=False;User ID=Tramcars;Password=ga711bm;Initial
> Catalog=Tramcars;Data Source=(local)"
> (User ID Tramcars exists in MSDE and is included in the db_owner role)
> This connects me OK and allows me to enter new data and save
> On creating a new entry and attempting to save again I get the message
> 'Login failed for user Tramcars'
> If I set 'Persist Security Info=True' in the connection string, all
> works fine
>
MSDE installs by default disabling standard SQL Server authenticated
connections..
thus only WinNT (trusted) connections will work..
you can modify this behavior both at install time, providing the
SECURITYMODE=SQL
parameter to the setup.exe boostrap installer, or later, at "run-time",
hacking the windows registry as described in
http://support.microsoft.com/default...b;en-us;285097
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
DbaMgr2k ver 0.15.0 - DbaMgr ver 0.60.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
-- remove DMO to reply
|||Hi Andrea
MSDE is set to mixed mode when this happens
Strange thing is it allows me to save once, but fails with message on second
save?
Regards
Steve
"Andrea Montanari" <andrea.sqlDMO@.virgilio.it> wrote in message
news:3n8lalFcjubU1@.individual.net...
> hi Steve,
> steve wrote:
> MSDE installs by default disabling standard SQL Server authenticated
> connections..
> thus only WinNT (trusted) connections will work..
> you can modify this behavior both at install time, providing the
> SECURITYMODE=SQL
> parameter to the setup.exe boostrap installer, or later, at "run-time",
> hacking the windows registry as described in
> http://support.microsoft.com/default...b;en-us;285097
> --
> Andrea Montanari (Microsoft MVP - SQL Server)
> http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
> DbaMgr2k ver 0.15.0 - DbaMgr ver 0.60.0
> (my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
> interface)
> -- remove DMO to reply
>
|||hi Steve,
steve wrote:
> Hi Andrea
> MSDE is set to mixed mode when this happens
> Strange thing is it allows me to save once, but fails with message on
> second save?
>
you mean you can connect with the provided connection string once, but if
you try a second time you get that exception?
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
DbaMgr2k ver 0.15.0 - DbaMgr ver 0.60.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
-- remove DMO to reply
|||Hi Andrea
Yes thats exactly what I mean
I can connect to msde when my program starts, to populate comboboxes etc
I always close the connection when not needed (con.close)
I can then create 1 invoice and save it OK, which requires..
con.open
code to save data....
con.close
If I then try to save another invoice
con.open
etc
con.close
Error raised at con.open (login failed for user Tramcarslogin)
It is like the connectionstring forgets the login password on the second
attempt
If I use persist security info=true in the connectionstring I don't get the
error and everything is OK
Regards
Steve
"Andrea Montanari" wrote:

> hi Steve,
> steve wrote:
> you mean you can connect with the provided connection string once, but if
> you try a second time you get that exception?
> --
> Andrea Montanari (Microsoft MVP - SQL Server)
> http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
> DbaMgr2k ver 0.15.0 - DbaMgr ver 0.60.0
> (my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
> interface)
> -- remove DMO to reply
>
>
|||hi Steve,
Steve wrote:
> Hi Andrea
> Yes thats exactly what I mean
> I can connect to msde when my program starts, to populate comboboxes
> etc
> I always close the connection when not needed (con.close)
> I can then create 1 invoice and save it OK, which requires..
> con.open
> code to save data....
> con.close
> If I then try to save another invoice
> con.open
> etc
> con.close
> Error raised at con.open (login failed for user Tramcarslogin)
> It is like the connectionstring forgets the login password on the
> second attempt
> If I use persist security info=true in the connectionstring I don't
> get the error and everything is OK
ok, I think I understand... or hope so...
you do something like
Dim sCon As String
Dim oCon As ADODB.Connection
Set oCon = New ADODB.Connection
sCon = "Provider=sqloledb;Data Source=(Local);Initial Catalog=pubs;User
Id=sa;Password=xxx;persist security info=false"
oCon.Open sCon
DoSomethingWithConnection oCon ' here you consume a recordset or command or
the like
oCon.Close
oCon.Open
DoSomethingWithConnection oCon ' here you consume a recordset or command or
the like
oCon.Close
Set oCon = Nothing
that's to say you open the connection the second time without providing a
connection string and relying on the old provided one..
the specific property, "Persist Security Info" is there to specify whether
or not the data source object is allowed to persist sensitive authentication
information (such as pwd) along with other info.. as it has been set to
false, there's no way for the 2nd open method to know such a kind of info,
and the provider will refuse to pass the connection on..
if this is the case, you should not rely on such a mechanism for 2 reason..
1st you always should completely destroy the ADODB.Connection object when
not needed,
oCon.Close
Set oCon = Nothing
so that all finalizers of the object will be properly called, and the conn
will return to the connection pool...
2nd, (and also becouse of the preceding one) you always should provide a
full qualified connection string...
is a comparable/compatible one can be found in the connection pool, it will
be picked up from there, or a new one will be createad ...
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
DbaMgr2k ver 0.15.0 - DbaMgr ver 0.60.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
-- remove DMO to reply
|||Hi Andrea
Thanks again for a great explanation
Explains everything
Regards
Steve
"Andrea Montanari" wrote:

> hi Steve,
> Steve wrote:
> ok, I think I understand... or hope so...
> you do something like
> Dim sCon As String
> Dim oCon As ADODB.Connection
> Set oCon = New ADODB.Connection
> sCon = "Provider=sqloledb;Data Source=(Local);Initial Catalog=pubs;User
> Id=sa;Password=xxx;persist security info=false"
> oCon.Open sCon
> DoSomethingWithConnection oCon ' here you consume a recordset or command or
> the like
> oCon.Close
> oCon.Open
> DoSomethingWithConnection oCon ' here you consume a recordset or command or
> the like
> oCon.Close
> Set oCon = Nothing
> that's to say you open the connection the second time without providing a
> connection string and relying on the old provided one..
> the specific property, "Persist Security Info" is there to specify whether
> or not the data source object is allowed to persist sensitive authentication
> information (such as pwd) along with other info.. as it has been set to
> false, there's no way for the 2nd open method to know such a kind of info,
> and the provider will refuse to pass the connection on..
> if this is the case, you should not rely on such a mechanism for 2 reason..
> 1st you always should completely destroy the ADODB.Connection object when
> not needed,
> oCon.Close
> Set oCon = Nothing
> so that all finalizers of the object will be properly called, and the conn
> will return to the connection pool...
> 2nd, (and also becouse of the preceding one) you always should provide a
> full qualified connection string...
> is a comparable/compatible one can be found in the connection pool, it will
> be picked up from there, or a new one will be createad ...
> --
> Andrea Montanari (Microsoft MVP - SQL Server)
> http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
> DbaMgr2k ver 0.15.0 - DbaMgr ver 0.60.0
> (my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
> interface)
> -- remove DMO to reply
>
>

Login failed for user

I installed Sales Logix (a database program) which uses
SQL Server MSDE. When you install Sales Logix, it
installs SQL Server; however, I was having trouble getting
SQL to install so worked with a Microsoft tech and we got
a default instance of SQL Server MSDE installed. Now,
when I try to attach my SLX database using the SalesLogix
Attach Remote utility, I get the following error:
[Microsoft][ODBC SQL Driver][SQL Server Driver][SQL Server]
Login failed for user 'sa'. Reason: Not associated with
a trusted SQL Server connection.
How would I associate this with a trusted SQL Server
connection? Any help would be greatly appreciated!
Leesa
hi Leesa,
"Leesa" <leesaforeman@.fccef.com> ha scritto nel messaggio
news:2f55001c46c41$0fa2ad50$a301280a@.phx.gbl...
> I installed Sales Logix (a database program) which uses
> SQL Server MSDE. When you install Sales Logix, it
> installs SQL Server; however, I was having trouble getting
> SQL to install so worked with a Microsoft tech and we got
> a default instance of SQL Server MSDE installed. Now,
> when I try to attach my SLX database using the SalesLogix
> Attach Remote utility, I get the following error:
> [Microsoft][ODBC SQL Driver][SQL Server Driver][SQL Server]
> Login failed for user 'sa'. Reason: Not associated with
> a trusted SQL Server connection.
> How would I associate this with a trusted SQL Server
> connection? Any help would be greatly appreciated!
> Leesa
MSDE install by default granting only Windows NT trusted connections, so SQL
Server authenticated connections, using "user" + "pwd" credential are not
allowed...
you can change this behaviour both at install time and later, using the
advices provided at
http://support.microsoft.com/default...b;en-us;285097
Andrea Montanari (Microsoft MVP - SQL Server)
http://www.asql.biz/DbaMgr.shtmhttp://italy.mvps.org
DbaMgr2k ver 0.8.0 - DbaMgr ver 0.54.0
(my vb6+sql-dmo little try to provide MS MSDE 1.0 and MSDE 2000 a visual
interface)
-- remove DMO to reply
sql

Monday, March 12, 2012

login faild for user

Hello
I wrote a program on my computer it has a SQL database. It works on my computer but when I upload it on the internet it makes an error.
Login failed for user 'webmaster'
In my control panel I add new MS SQL SERVER database with the name=kelec, username = xx and password = xxxx
I think the problem is in my connectionstring what is the correct connectionstring for my connection.

Please help me
Best regards
KocholHi
I searched the MSDN for this problem and I found this.
I add username and password but I'm getting in new error.
Login failed for user 'NT …/NETWORK'

By default, ASP.NET applications run in the context of the local user called ASPNET in Windows 2000 and Windows XP or NETWORK SERVICE in Windows Server 2003. These user accounts have limited permissions. However, the ASPNET or NETWORK SERVICE user is local to the Web server computer and is therefore not recognized as a user on remote computers. To get around this limitation, you can have your application run in the context of a Windows domain user that is recognized on both the Web server computer and on the SQL Server computer.
Mapping your application process to a Windows domain user requires that you configure the following processes:
?The Web server computer You must be sure that the Windows domain user you specify has sufficient privileges (but no more) to run a Web application.
?Your application You need to configure the Web.config file to specify that ASP.NET use integrated security, which allows ASP.NET to recognized the mapped user name.
Note For information on the machine.config and Web.config files, see ASP.NET Configuration.
?Connection string When you create connection strings for connection objects in your application, you need to specify that they will use integrated security.
?SQL Server You need to add the specified domain user as a SQL Server login user.
Configuring Users on the Web Server Computer
To set user permissions for the Windows domain user
?Using Windows administrative tools on the Web server computer, make sure that the mapped Windows domain user has necessary privileges. For details, see ASP.NET Required Access Control Lists (ACLs).
Mapping to the Windows User and Enabling Impersonation
After establishing the correct permissions for the ASPNET or NETWORK SERVICE user account and for the user to map to, you configure the application to impersonate that user.
To configure your Web application for integrated security
?Open the Web.config file for your application and add the following elements:
?<authentication mode="Windows" />
<identity impersonate="true" userName="domain\username" password="password"/>
The <authentication> element might already be there.
Note Elements in Web.config are case sensitive.
Using Windows Security in the Connection String
Finally, when you create connection strings for database access, configure them to use Windows integrated security.
To use Windows security in the connection string
?When you create a connection string for your application, do not include a user name and password. Instead, set the connection string's Integrated Security attribute to SSPI.
The following example shows a connection string that includes the appropriate attributes:
data source=myserver;initial catalog=northwind;Integrated Security=SSPI
To configure SQL Server for integrated security
1.From the Windows Start menu, choose Microsoft SQL Server, and then choose Enterprise Manager.
2.Open the node for the server and expand the node for the database you want to give users permissions for.
3.Right-click the Users node and choose New Database User.
4.In the Database User Properties dialog box, enter domain\username in the Login name box, and then click OK.|||I assume you are using ASP.NET since you are in this forum. Try this:


Dim dbconn As New OleDbConnection
Dim strServer As String = "server" <-- your server name
Dim strDbName As String = "dataBaseName" <-- your DB name
Dim strUId As String = "xx"
Dim strPwd As String = "xxxx"

dbconn.ConnectionString = "PROVIDER=SQLOLEDB;" & _
"DATA Source=" & strServer & ";" & _
"Initial Catalog=" & strDbName & ";" & _
"User ID=" & strUId & ";Password=" & strPwd

Good luck!
-Gabian-

Login Error

Hi

I am using MSDE2000 and ASP.NET. I have 3 data adapters and a dataset. When running the program I get:

Exception Details: System.Data.SqlClient.SqlException: Login failed for user 'CGREGORYT2XP\ASPNET'.

Source Error:
Line 257: If Not Page.IsPostBack Then
Line 258:
Line 259: SqlConnection1.Open()
Line 260:
Line 261: SqlDataAdapter1.Fill(Ds1, "employee")

I have used sp_grantdbaccess 'machinename\ASPNET' on PUBS but still get error.

Where am I going wrong??

Thanks

I pressume you have added a user to the SQL Server for CGREGORYT2XP\ASPNET and that the SQL server supports Mixed Mode authentication.

If not check you have a user by selecting "Security", "Logins" in Enterprise Manager you should see a user in the list called CGREGORYT2XP\ASPNET.

Friday, March 9, 2012

Logical XOR operator in T-SQL (SQL Server 2000)

Hi all....

I was wondering why SQL Server 2000 lacks a logical XOR operator. Do you have a ready to use function that implements it?

How can I program one by myself? I know that A XOR B is equivalent to NOT A * B + A * NOT B. So I tried to create this function :

CREATEFUNCTION XOR

(

-- Add the parameters for the function here

@.A BIT,

@.B BIT

)

RETURNS BIT

AS

BEGIN

RETURNNOT @.A AND @.B OR @.A +NOT @.B

END

But it didn't compile.

How can I pass boolean values as parameters? any other hint?

Thanks

Jaime

There is an XOR operator -- it is the caret (^). In the Books On-line look up operators(symbols) bitwise.|||

As you said, that is a bitwise operator, not a logical one.

For example, using the ^ I couldn't do something like :

SELECT *

FROM TABLE

WHERE (A = 10) ^ (B = 5)

which should return records when either A = 10 or B = 5, but if conditions are both satisfied or both not satisfied, I don't want records to be returned.

Another suggestion to accomplish that? Of course this is a simplified scenario. In case of 2 conditions I can do perfectly :

WHERE (A <> 10 AND B = 5) OR (A = 10 AND B <> 5)

The only solution I see is to implement a XOR function myself and to nest them, but I couldn't (or don't know how) pass a boolean value as a function parameter. If you know how, please tell me.

Thanks

Jaime

|||

There is no boolean data type in TSQL and there are only few system built-ins like CONTAINS that can be used directly in a WHERE clause. So you need to use the XOR operator and test for the return value of expression like:

WHERE (case A when 10 then 1 else 0 end)^(case B when 5 then 1 else 0 end) = 1

|||? The reason your UDF does not work is that BIT is not the same as BOOLEAN. There is no Boolean type in SQL Server, so you can't do: SELECT * FROM Table WHERE Column Instead, (assuming that Column is typed as BIT) you have to do: SELECT * FROM Table WHERE Column = 1 Anyway, it's quite easy to do XOR inline: SELECT * FROM Table WHERE (Column1 = 1 AND Column2 <> 1) OR (Column1 <> 1 AND Column2 = 1) -- Adam MachanicPro SQL Server 2005, available nowhttp://www..apress.com/book/bookDisplay.html?bID=457-- <Jaime Stuardo@.discussions.microsoft.com> wrote in message news:b2649891-1305-4b27-a074-5b0a896807e8@.discussions.microsoft.com... Hi all.... I was wondering why SQL Server 2000 lacks a logical XOR operator. Do you have a ready to use function that implements it? How can I program one by myself? I know that A XOR B is equivalent to NOT A * B + A * NOT B. So I tried to create this function : CREATE FUNCTION XOR ( -- Add the parameters for the function here @.A BIT, @.B BIT ) RETURNS BIT AS BEGIN RETURN NOT @.A AND @.B OR @.A + NOT @.B END But it didn't compile. How can I pass boolean values as parameters? any other hint? Thanks Jaime