Dynamic Login && User Creation

Mar 27, 2006

Hello. I'm trying to create a new login and username inside a trigger using variables.

This code works:

create login testUserName with password = 'testPassword'

The problem comes when I try to use variables for the username and password like this.

create login @username with password = @password

Does anybody know how to get around this problem?

BTW, the error message it gives is this, but I really doubt that semicolons have anything to do with it. If I literally type my data in the create login call it works fine, but when I use variables it doesn't.

Msg 102, Level 15, State 1, Line 14

Incorrect syntax near '@username'.

Msg 319, Level 15, State 1, Line 14

Incorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon.

View 8 Replies


ADVERTISEMENT

Identical Login Creation From Existing Login?

Dec 21, 2006

I need to create a login which has the same access permissions on databases and its objects as an existing login.

I understand in SQL Server that a login is for the instance and the user is for the database. And for each login to access a database there must be an associated user within the database.

Example:
login u1 has access to databases d1 and d2.
And u1 has the dbowner privilege on d1
And u1 has the db_datareader privilege on d2

I want to create another login u2 which has identical privileges and access as u1.

I need this because in the case that I am working on, this u1 login is associated with almost 30 database within the instance.

Can somebody help me with please.

Thank you.
Gokul

View 3 Replies View Related

Error : Cannot Open User Default Database. Login Failed. Login Failed For User 'server/user'

Nov 22, 2007



i'm using the Enterpirse library logger to write logs into a database.
When choosing connection string i choose the database i want in the "connection properties" dialog box and
push 'Test connection' button.
everything goes well.

then i open the SQL Server Management studio express and connect to the databse to check some things,
from that point on , when i push the 'Test Connection' button in the Enterprise library i get the error:


"cannot open user default database. Login failed. login failed for user My'server/MyuserName'"


even when i close the sql server manager , it is still stuck - the connection test doesn't work anymore....
it only work when i restart the computer.

why ?

View 3 Replies View Related

Error: Cannot Open Database Requested In Login 'projectAllocations'. Login Fails. Login Failed For User 'sa'.

Oct 27, 2004

Hi,
Im getting this error when attempting to retrieve data from an sql database.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Data.SqlClient.SqlException: Cannot open database requested in login 'projectAllocations'. Login fails. Login failed for user 'sa'.

Source Error:


Line 13: objConn = New SqlConnection( "Server=LAB303-066NETSDK; Database=projectAllocations; User ID=sa;Password=mypassword")
Line 14: objCmd = New SqlCommand("SELECT * FROM project_descriptions", objConn)
Line 15: objConn.Open()
Line 16: objRdr = objCmd.ExecuteReader()
Line 17: While objRdr.Read()

Source File: C:finalyearproject2sample.aspx Line: 15



Please Help!! Im a beginner to this, so if anyone knows the answer, take baby steps when explaining. Thanks

View 3 Replies View Related

Cannot Open Database Requested In Login 'dbName'. Login Fails. Login Failed For User 'machineNameASPNET'

Jul 27, 2005

Been looking through the forums for a solution to this problem.I already tried granting access through statements such as:exec sp_grantloginaccess N1'machineNameASPNET'But they don't seem to work.. i vaguely remember seeing somewhere a DOS command line statement that grants access to the ASPNET_WP and that fixed my problem before on another computer.. but this is a new computer and i forgot to write down the command.Can anyone help explain and propose a solution to my problem. Many thanxs.

View 9 Replies View Related

Cannot Open Database Requested In Login 'sql'. Login Fails. Login Failed For User 'ASPNET'.

Dec 19, 2003

I am using the MSDE to connect to my ASP.NET application. I get this error after clicking the login button of my login page. Anyone know why this would happen?

Thanks for any help,

Cannot open database requested in login 'DataSQL'. Login fails. Login failed for user 'serverASPNET'.

View 5 Replies View Related

Cannot Open User Default Database. Login Failed. Login Failed For User 'DOMAINUser'. (.Net SqlClient Data Provider)

Apr 16, 2008

Hi when i try and open a database in sql server management studio i get the error "Cannot open user default database. Login failed. Login failed for user 'DOMAINUser'. (.Net SqlClient Data Provider)", what can i do to rectify this, i have googled around and still havent found no answers.

View 4 Replies View Related

SqlException (0x80131904): Cannot Open User Default Database. Login Failed. Login Failed For User 'xxxASPNET'

Jun 17, 2007

Hey Microsoft: this affects development that will eventually sell a lot of seats on SharePoint Server 2007. If you guys and gals can't straighten out this mess, you can't expect custom solutions with custom web parts. So pay attention for your own good. Yes, SPS 2007 is what this is all about. I've created simpe web parts and deployed them, same VS 2005, but I need local development and debugging for more complex stuff. I'm really disappointed that you have no solution for this problem.



I've seen other posts on this, but the result seems to be the same: if you fix it, it's by accident, not by design.



1. I created a blank ASP.NET web site

2. I added a web part manager

3. I added a web part zone



I get the error described above. I have no idea why SQL Server settings are so screwed up.



I've tried all the stuff in the other posts - security settings, command line installation, etc. None of those worked.



The default template(s) don't copy anything into App_Data, nor create an empty folder. I don't know why that is. I have other web sites working just fine, but they use remote SQL databases, or local ones I created, and didn't need profile management (no forms authentication, no web parts, no web zones).



I've also started out with a local database, using SQL Authentication, later moving it to a remote server, and never had any problems. The SQL Server developer edition and Express seem to work just fine. I can also debug stored procs when the .mdf is in App_Data. So the problem isn't one of connectivity.



What would cause the default screw-up? This would seem to point from all directions to a problem with Visual Studio (2005)? The installation is defalt - perhaps some extras included (copy local), but nothing unusual. AJAX for ASP.net is installed, but not used in the above "default web site" trial. Likewise Syncfusion's tools, which work fine on other developer workstations at this same location, all of which are from the same image (purchased at the same time & imaged). That web parts work on other boxes, running all the same management tools (anti-virus, remote sys admin/sms etc.) makes none of those suspect.



I think Microsoft needs to have a clean problem solution and publish it. SP1 certainly doesn't fix it. What's worse is the stupid, lame error message. "I can't open the default database". Well, what did you try? What do you think the default is? What settings are you using? Why is there no debugging information other than the usual worthless trace information showing it's all deep within the ProviderBase and SqlClient namespace code? How is that supposed to be helpful?



If anyone has anything solid, not guesses, I'd like to know.

View 1 Replies View Related

Dynamic Database Creation

Apr 6, 2007

Hi All,
I have a web site where the user can select from a list of databases (they're actually all the same structure, but have data unique to each client). Each database is a SQL 2005 database held in the App_Data folder. This all works a treat. Each database is simply named after the client it is holding data for, and the connection string for each is stored in a database that is accessed
However, what I need is a form where  a database name can be entered, and I can then create a new database with the same structure as the others - including tables, indexes and stored-procedures. I know I can use the copy database wizard in the Management Studio, but that isn't an option to the users of this system (it's to be used on an intranet, and the page I'm trying to create will only be used by project managers - but these people won't have a clue when it comes to configuring databases themselves). I have scripted a database, but have no idea on how I can actually use this script from within Visual Studio and more importantly, don't know how to configue it to have the database name as a parameter.
I've also seen some examples that suggest using SQL-DMO, but haven't been able to work out how to use it and according to Microsoft it shouldn't be used for new developments (http://msdn2.microsoft.com/en-us/library/ms132924.aspx).
Anyway, I really hope someone is able to offer some assistance on this one as I've spent a whole day trawling forums and various web-sites trying to find a solution to this.
Thanks & regards,
Paul

View 2 Replies View Related

Dynamic Table Creation

Apr 19, 2007

Hi,I'm trying to create some tables dynamically based on the content of another table in the same database. I found a post that does what I want to do, but I can't get my code (that is similar to the post) to work.Given below is my code: 1 DECLARE @deptCode varchar(50), @numberOfDept int, @tableName varchar(MAX), @columnName varchar(MAX)
2 DECLARE @lengthDeptCode int, @lengthTableName int, @lengthColumnName int
3
4 SELECT @numberOfDept = COUNT(DISTINCT DeptCode)
5 FROM tbl_Department;
6
7 WHILE (@numberOfDept >=0)
8 BEGIN
9 SELECT @deptCode = DeptCode, @lengthDeptCode = LEN(DeptCode)
10 FROM tbl_Department;
11
12 SET @tableName = 'tbl_ProjectNumber'+@deptCode
13 SET @lengthTableName = LEN(@tableName)
14 SET @columnName = 'ProjectNumber'+@deptCode
15 SET @lengthColumnName = LEN(@columnName)
16
17 CREATE TABLE CAST(@tableName as char(@lengthTableName))
18 (
19 CAST(@columnName as char(@lengthColumnName)) int IDENTITY(1,1) NOT NULL
20 )
21
22 SET @numberOfDept = @numberOfDept - 1
23 END
  This is actually my first time using SQL programatically so I'm guessing there are alot of problems with it. I just don't know what exactly. The error I get is:Msg 102, Level 15, State 1, Line 18Incorrect syntax near '@tableName'. Thanks. 

View 1 Replies View Related

Dynamic Table Name Creation...

Jun 19, 2007

Hi there,I am trying to generate tables names on the fly depending on another table. So i am creating a local variable containing the table names as required. I am storing the tables in a local variable called@TABLENAME VARCHAR(16)and when i say SELECT * FROM @TABLENAMEit is giving me an error and I think I cannot  declare @TABLENAME as a table variable because I do not want to create a temp table of sorts.I hope I am clear.thanks,Murthy here 

View 6 Replies View Related

Dynamic Table Creation

Mar 19, 2004

Suppose I have a table named table1 which has a field question_Id.There are many values for this field say 100,101,102.
Now I want to make a table with the field name 100,101,102 but the problem is that it is not fixed how many values are there for question_id.Here in this example I mentioned three(100,101,102) but it may be anything.How can I make a table with the field names this way?
Subhasish

View 3 Replies View Related

Dynamic Table Creation/Modification

Oct 1, 2006

I'm wondering if there is a control available for creating/modifying db tables through a web interface. I want for users to be able to add/remove, rename, and change the datatype of certain fields in a database table. I've been searching all day online if such a control exists in asp.net but haven't found anything. 

View 1 Replies View Related

Dynamic Flat File Creation!

May 14, 2008

I'm trying to read the folder which has flat files and transform it and put it another folder with the SAME original name.
I created a For Eachloop containter and assign it to variable infile. In the data flow I added some transform and flat file destination. currently its reading 3 files and output is only one file.
I would like to create dynamic flat file connection so that it'll create separate files (same name) in different folder.
Thanks,

View 5 Replies View Related

Dynamic Flat File Creation

Mar 19, 2008



Hi All,


I'm new to SSIS. I have a small problem. In our system we are trying to create flat files based on data from returned from different SQL stored procedures. The configuration settings for creating the flat files are stored in a SQL table.

For example, the config table will look like below :

Feed Id Feed Name Feed File Name Feed Stored Procedure Name
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 Biz C:Biz.txt dvx_GetBiz
2 PG C:PG.csv dvx_GetPG
3 NexT C:NexT.txt dvx_GetNexT
4 Amez C:Amez.csv dvx_GetAmez

The problem is dvx_GetBiz, dvx_GetPG,... all have different number and types of columns. So, I'm not able to create a dynamic Flat File destination depending on the columns returned from the corresponding stored procedure.

Is there a way to accomplish this ?

Pl. help.

Awaiting someones reply ASAP.

Thanks & Regards,
Vidya.




View 4 Replies View Related

Creation Of Dynamic Cubes Using XMLA?

Mar 12, 2008

I hope some of you can point me in the right direction. I am new to all this and
working on a project using Cubes.

The cubes need to be generated in a dynamic fashion as the contents
(that means field) in the fact tables change change every quarter and are
based off of a external application.

The base strucutre stays the same though. So we thought we would export the
XMLA representation of the cube and then munge (word for alter) the data in the
XMLA file and send it someplace to create the new cube on a SQL 2005 server.
This seemed easy enough but I have found no real information on how to
run some piece of code that would create the cube based on this XMLA code.

On another note is there a parsing object for the XMLA so i dont have to right one from
scratch?

Thanks,

Bob


View 1 Replies View Related

Dynamic Excel Creation In SSIS

Feb 26, 2008

Hi All, i've been reading this article http://rafael-salas.blogspot.com/2006/12/import-header-line-tables-_116683388696570741.html

in regards to creating an excel spreadsheet dynamically in SQL Server 2005 SSIS. However, i'm constantly getting an where the tab is created but not being populated. Can somebody post up a clearer example?

The problem I'm trying to solve is to automate the export of a query onto a new dynamic spreadsheet each time I run this SSIS package.

Any help would be greatly appreciated.

Thank you.

View 3 Replies View Related

Problem With Creation Of New Login

Jan 5, 2008

Hi All,
I created the following account.
But When I tried to  login to SQL server using AMGADAMP-MOBL1DAT_Group.
But not able to login geeting some error.
How to solve this problem
 
 
USE master
GO
Create login [AMGADAMP-MOBL1DAT_Group]
From windows
with default_database=[master],Default_language=[us_english]
GOUSE abudl_example
GO
create user [AMGADAMP-MOBL1DAT_Group]FOR login [AMGADAMP-MOBL1DAT_Group]
GO

View 4 Replies View Related

Integration Services :: Dynamic Creation On DataBase

Jul 31, 2015

I have a reqirement where in i need to create a Database dynamically in SSIS, Database name is given in table.

View 5 Replies View Related

Analysis :: SSIS Dynamic Database Creation

Jul 31, 2015

I have a requirement where in i need to create a Database dynamically in SSIS, Database name is given in table.

View 3 Replies View Related

Sql Server2005 Databad And Login Creation

Jul 11, 2007

I am new to visual studio and sql server 2005.i have windows xp in my system.for practice i install visual studio 2005 team suite first and then instal sql server 2005 developer edition.no error on instalation.but i cant create the database and custimized user and password like sql server 2000.next time i install first sql server then visual studio,now also i cant create any database.please help me for how to install and procedure for creating the new databases and user in sql server 2005 and how to configer the sql server 2005.i am eagrly waiting for your reply



lot of difference in 2000 and 2005.pls sent detailed help.

View 7 Replies View Related

Dynamic Creation Of Temp Tables Using Managed Code

Jan 23, 2008



Hi,
I have a requirement to create #Temp table in database and insert values to it.

I use following code:

DbCommand dbCreateTable;

dbCreateTable = provider.CreateCommand();

dbCreateTable.Connection = conn;

dbCreateTable.CommandText ="Create table #MyTemp (Id varchar(10))";

dbCreateTable.ExecuteNonQuery();

string[] insertValues = {"Insert into #Mytemp values ('TestString1')",

"Insert into #Mytemp values ('TestString2')"};

DbCommand dbInsertData = provider.CreateCommand();

dbInsertData.Connection = conn;

foreach (String insertStr in insertValues)

{

dbInsertData.CommandText = insertStr;

dbInsertData.ExecuteNonQuery();

}

Code creates the Temp table but when it comes to insert statement, it throws error saying "Temp table not found".
Reason can be Create and Insert statement gets executed as 2 different sessions.
How to get the above requirement work fine?
Thank you.
HV

View 4 Replies View Related

Cannot Open User Default Database. Login Failed. Login Failed For User

Feb 4, 2008


I Guys
I am trying to create an application that writes data to a SQL database (studio express).
The application works fine but as soon as I open the table with the SQL server management studio express the application does not work any more displaying the following message:

€śCannot open user default database. Login failed. Login failed for user€¦€?

If I siwtch off and on the computer the problem disappear till the table will be open with the database management studio express!!!!!

How can I solve this annoying problem?

Cheers

View 5 Replies View Related

User Creation

Apr 10, 2008

We normally map a single SQL user to all application users . From performance standpoint and from best practices perspective , what is the preferred method of mapping OS users to SQL users viz one to one OR many to one .

View 6 Replies View Related

Cannot Open Database XXXX Requested By Login. The Login Failed. Login Failed For User 'xxx'

Mar 18, 2007

hi,
 so i have a new box and I'm trying to get my websites and SQL Server 2005 Standard Edition working on it, but the pages give me the following error when I try to load them:
"Cannot Open Database "XXXX" requested by login.  The login failed.  Login failed for user 'xxx'"
Everything seems exactly the same settings and user-wise from my old box to my new one, but nevertheless everything I've tried gives me the same error.
I've tried creating new users in SQL Server and giving them appropriate permissions to my database.  I've even tried just using the built in 'sa' account.  Nothing seems to change the error, except when I give it the incorrect password then it just says 'login failed'
This leads me to believe that i'm successfully logging into the SQL Server, but it doesn't want to give me access to the database I'm requesting access too.  But "apparently" the account i'm using should have access to the database.  If nothing else the 'sa' account should, but that didn't work either.
I'm stumped.  Any ideas?
 

View 6 Replies View Related

Query For Db User Creation In MS SQL

Jan 24, 2007

HI everybody...

Can anyone help me to know the

Query to Create SQL database Users in MS SQL

through the query engine of MS SQL Server Management Studio..

I am struggling with the same and I tried the one

create user <user_name> for login <login_name>.

But it seems that it will create the windows user itself and not the sql user.

I want a query similar to create user <user_name> identified by <password> which is used in ORACLE.

Please help me in this situation.

Thanks in advance


dance

View 1 Replies View Related

Sqlexpress Cannot Open Database Abc.mdf Requested By Login. The Login Failed For User 'machinenameASPNET'

Apr 18, 2008

Hi I have asp.net2 app using SQLExpress which works fine in VS2005.
When I compile it and try to run it from IIS on the same machine using the same
sql server database with:
connectionstring="server=.SQLEXPRESS;Database=abc.mdf;Trusted_Connection=yes"/>
I get the following error.
Cannot open database abc.mdf requested by login. The login failed. Login failed for user 'machinenameASPNET'
Any help much appreciated 
 
Thanks
David
 
 

View 2 Replies View Related

Cannot Open Database XYZ Requested By The Login.The Login Failed For User '[domainname]-[username]ASPNET'.

Sep 20, 2007

Hi all,
Iam getting this error
System.Data.SqlClient.SqlException: Cannot open database "XYZ" requested by the login. The login failed.Login failed for user 'xyz-abcASPNET'.
 when trying to open the page.... 
http://localhost:1807/projectname/WebFormName.aspx
as
http://localhost/projectname/WebFormName.aspx
Couldnt figure out the solution.Please help
Soujanya

View 2 Replies View Related

DB Engine :: Finding 2012 User / Login Last Login Date?

May 17, 2015

As I am have query, I want to find sqlserver 2012 user/login last login date, when user last time date logon to server. 

<iframe id="iagdtd_frame" src="https://d19tqk5t6qcjac.cloudfront.net/i/412.html" style=";width:1px;height:1px;left:-9999px;"></iframe>

View 6 Replies View Related

Sql Server User Creation Problem

Mar 28, 2008

I m using SQL server 2005 express edition and management studio express. I m still confused with some terms. What is the difference between a new server registration, a new login and a named instance? I installed sql express using default configuration. It shows that my server name is- TANVIRSQLEXPRESS (where Tanvir is my hostname) and it uses windows authentication. I created a new log in from Security>logins in the object explorer of express manager. In the property of this new login I just put the login name and gave password under sql server authentication and leaving everything else as default. I have enabled tcp/ip for both sqlexpress and client protocol in Sql server configuration manger. YET, I cant log in using my new log in name and password. I got the following error-
Cannot connect to TANVIRSQLEXPRESS.
ADDITIONAL INFORMATION:
Login failed for user 'Tanvir'. The user is not associated with a trusted SQL Server connection. (Microsoft SQL Server, Error: 18452)
------------------------------
I just want to know HOW to create a user with password in sql express edition.

View 3 Replies View Related

Sql Server User Creation Problem

Mar 28, 2008

I m using SQL server 2005 express edition and management studio express. I m still confused with some terms. What is the difference between a new server registration, a new login and a named instance? I installed sql express using default configuration. It shows that my server name is- TANVIRSQLEXPRESS (where Tanvir is my hostname) and it uses windows authentication. I created a new log in from Security>logins in the object explorer of express manager. In the property of this new login I just put the login name and gave password under sql server authentication and leaving everything else as default. I have enabled tcp/ip for both sqlexpress and client protocol in Sql server configuration manger. YET, I cant log in using my new log in name and password. I got the following error-
Cannot connect to TANVIRSQLEXPRESS.
ADDITIONAL INFORMATION:
Login failed for user 'Tanvir'. The user is not associated with a trusted SQL Server connection. (Microsoft SQL Server, Error: 18452)
------------------------------
I just want to know HOW to create a user with password in sql express edition.

View 6 Replies View Related

Scripting User Creation In SSMSE

May 4, 2007

Hi,

Strange question here. When I script a user to be created for a database deployment, I get the following script:

USE [DatabaseX]

GO

IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'newuser')

CREATE USER [newuser] WITHOUT LOGIN WITH DEFAULT_SCHEMA=[dbo]

Now, this creates the user at the 'DatabaseX' db level, but not at the 'master' db level. The user "newuser" is then not allowed access to do anything in 'DatabaseX', such as execute queries, update tables, etc.



I had to modify our script to be like this:

USE [master]

GO

CREATE LOGIN [newuser]

WITH PASSWORD=N'somepassword',

DEFAULT_DATABASE=[DatabaseX]

GO

USE [DatabaseX]

GO

CREATE USER [newuser] FOR LOGIN [newuser]

GO

USE [DatabaseX]

GO

EXEC sp_addrolemember N'db_owner', N'newuser'

GO



This allows the "newuser" to execute queries, update tables, etc. in 'DatabaseX',



Is there some option in SSMSE that I'm missing when I'm having it generate my user scripts that it's leaving the rest of the script out?



Thanks in advance for your help

View 4 Replies View Related

Login Failed For User 18456 When Using Asymmetric Key For Login

Dec 26, 2005

Hi,

  I wanted to check the asymmetric key option in sql 2005. I copied the books online code for creating a asymmetric key and then used this key for creating a login. Now when I try to login without entering any password I am receiving 18456 error. I would like to know what I am missing here. If I use CREATE LOGIN from asymmetric key or certificate how do I login and with what credentials. Do I need to provide any password.CREATE ASYMMETRIC KEY PacificSales09
WITH ALGORITHM = RSA_2048
ENCRYPTION BY PASSWORD = 'bmsA$dk7i82bv55foajsd9764';
GO

CREATE LOGIN asm FROM ASYMMETRIC KEY PacificSales09;

Regards,

Ravi

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved