I'm trying to connect via SSMS to our MS SQL Server 2005.
I first tried to connect via visual studio programmatically.
It worked after I found out that I have to put "Integrated Security=SSPI;" into the connection string, otherwise it refused the connection with a "login failed" error.
Now Im trying to connect via the SSMS but now I get also a refuse when I try to connect.
Sadly there is no option where I can set "Integrated Security=SSPI" or something else.
Choosing the "Windows Authentication" option in the Connection Dialog for SSMS is equivalent to putting "Integrated Security=SSPI" in the connection string.
This will use the credentials of the SSMS process when connecting to the server.
As a note you can also achieve this same result by using the "Additional Connection Parameters" text box. Click on the "Options >>" button at the bottom of the Connection Dialog and select the "Additional Connection Parameters" tab.
Then enter in the text "Integrated Security=SSPI" (without quotes) into the text box. This will override whatever the Authentication option chosen in the drop-down menu is.
More information can be found in the MSDN page or by pressing F1 when the Connection Dialog has focus.
Related
I had a database server for school and since the semester is over I no longer am on this server. I want to take all my projects and put them on my website I've been working on. The problem is they have the school server connection. On the back end when I want to open a connection to my local database how would I do this? My connection looks like this
SqlConnection con = new SqlConnection("Data Source=LocalServerName;");
I get an error about the user, but my username for my local connection has a \ in it and that's an invalid key so I can't put my username in
Try this....
string connectionString = "Integrated Security=SSPI;Initial Catalog=master;Data Source=(local)"
SqlConnection con = new SqlConnection(connectionString);
You can change the value for Initial Catalog from "master" to the name of your database. I'm assuming you're using integrated security (you login to SQL Server with your Windows account).
If your login failed, look in SQL Server's error log for a failed login attempt. The error will give you more details about why the login attempt failed.
If you're logging in using a domain account - a.k.a., Windows authentication, a.k.a., Integrated Security - you'll include the following in your connection string:
Integrated Security=SSPI;
If you are connecting with a SQL Server username (username and password maintained by SQL Server and NOT by Windows or Active Directory). You'll use the following:
Persist Security Info=True;User ID=<username>;Password=<password>;
If you're not 100% sure how to create your connection string, try this trick:
Create a text file on your desktop named "test.udl"
Once created, double click on that file.
You can set all the properties of your connection string here.
When you're done, hit OK.
Then open the file in a text editor (e.g., notepad).
You'll see a connection string configured with the options you previously set. Copy and paste.
I'd like to remove the initial "Connect to Server" dialog that pops-up at the startup.
As I prefer using the "Registered Servers" list to access my servers, that dialog is simply annoying.
I'm using SQL Server Management Studio 2012, if thats important.
Thanks
Tools -> Options -> Startup
At Startup: Open empty Environment.
It's actually Object Explorer and/or a query window and/or activity monitor that's asking for you to connect - so it has something to work with. All of the options other than "Open empty environment" require some kind of connection to work.
I've been trying to add a datasource in the ColdFusion Administrator for Windows 8 and I've been having many issues.
Below is what I've done:
Database created "onessBlog".
Login created onessBlog with password onessBlog / SQL Server Authentication pointing to default database onessBlog
User onessBlog created with default schema of dbo.
Named Pipes enabled for SQLEXPRESS
TCP/IP - All IP1 to IP11 is Active, Enabled, TCP Dynamic Ports is blank and TCP Port is 1433.
Service has been restarted.
Under data sources in ColdFusion Administrator, I create a datasource name 1ssBlog with the Microsoft SQL Server. I filled in the following fields:
CF Data source Name: 1ssBlogg
Database: onessBlog
Server: 127.0.0.1 and localhost
Port: 1433
User name: this is blank
Password: this is also blank
Once I verify the connection, I get the following error: Cannot open database "onessBlog" requested by the login. The login failed.
I have viewed the following resources and I don't know what I missed:
Adobe Docs
Local SQL Server 2008 ColdFusion Datasource
How do you configure a ColdFusion 8 datasource to connect to a local SQL Server 2008 server?
As Miguel-F commented above, he asked me why the username and password fields were blank. I replied that, according to the Adobe Docs, it advised me to leave the username and password fields blank. Obviously, this wasn't the case. Outlined below are the steps of getting a new instance SQL Server connected with ColdFusion:
Using SQL Server Management Studio, add a new database by going to the Object Explorer, right click on "Databases" and clicking on "New Database". Enter a name and leave at defaults for development purposes.
While still in the Object Explorer, under "Security" right on "Logins" and select "New Login". Enter a login name and choose "SQL Server authentication". For development purposes, uncheck at least "User must change password at next login"
Still in the Object Explorer, expand the new database that was created and right click "Security" and select "New User". Select User Type "SQL user with login" and type a user name. For "Login name", press the three dots button "..." and browse to and select the username created above. Select default schema as "dbo" for development purposes.
Video "Create user in SQL Server 2008 R2"
Exiting SQL Server Management Studio, go to sql Server Configuration Manager. Expand "SQL Server Network Configuration" and select "Protocols for SQLEXPRESS". Enable "Named Pipes" by right clicking.
Double click on "TCP/IP". In the IP Addresses tab type "Yes" for each "Enabled" field where "Active" is "Yes". Delete any entries to "TCP Dynamic Ports" and enter "1433" for any "TCP Port".
Save changes and selecting "SQL Serve Services" right click on "SQL Server" and restart the service by right clicking and clicking "Restart".
Local SQL Server 2008 ColdFusion Datasource
Log in to ColdFusion Administrator. Should be http://127.0.0.1:8500/CFIDE/administrator/index.cfm if left at defaults. Click on "Data Sources". Type in a Datasource name and select "Microsoft SQL Server" as the Drive Type.
In the "Database" field, enter the name of the database created in step 1.
In the "Server" field, enter 127.0.0.1 with "Port" 1433.
In the "User name" field, enter username created on step 2 and was selected in step 3.
In the "Password" field, enter the password for that username.
Submit and if it didn't verify, verify the connection.
I have a Visual Studio C++ project (unmanaged C++) in which I try to connect to a SQL Server 2008 instance on another machine in the LAN. I use TCP/IP. My connection string is:
"DRIVER={SQL Server Native Client 10.0};Server=tcp:169.254.204.232,1433;Network Library=DBMSSOCN;Initial Catalog=myDB;User ID=myDBUser;Password=myPassword;"
Important fact: I am able to successfully connect remotely to that instance with user id myDBUser and password myPassword using SSMS -- using SQL Authentication mode (and specifying TCP/IP in the connection options)! Also, once logged in I can successfully navigate the database myDB.
So yes, I have enabled Mixed mode authentication on my server.
Also note that the same code was successfully connecting when my instance was local and I was using Windows Authentication. In other words, what changed since this whole thing last worked is that I moved my server to another machine, am now using SQL Authentication, and therefore changed my connection string -- the code has otherwise not changed at all.
Here is the error message I get in my SQL Server 2008 instance's Server Logs:
Login failed for user ". Reason: An attempt to login using SQL Authentication failed. Server is configured for Windows Authentication only.
Error: 18456, Severity: 14, State: 58.
Notice that the user being quoted in that error message is blank, even though in my connection string I specify a non-blank user ID.
Other connection strings I tried that give the same result:
"DRIVER={SQL Server Native Client 10.0};Server=MACHINE2;Database=myDB;User ID=myDBUser;Password=myPassword;" (where MACHINE2 is the windows name of the machine hosting the sql server instance.)
I do not specify an instance name in the above connection string because my instance is installed as the default instance, not a named instance.
Any ideas on how to solve this?
UPDATE: I solved this problem it seems. Are you ready to find out how silly and totally unrelated that error message was?
In the connection string, I just changed "User ID" to "uid" and "Password" to "pwd", and now it works.
I now see "Connected successfully" in my SQL Server logs...
Try running SELECT SERVERPROPERTY('IsIntegratedSecurityOnly'); if it returns 1 is Windows Authentication if 0 Mixed. If it returns 1 is definitely Windows Authentication and there must be something else wrong.
I think I solved this problem by doing this...
right click on servername on object explorer -> Properties -> Security -> Changed server authentication to SQL server and Windows authentication mode -> click OK.
after that open server on object explorer -> Expand security -> Expand Login -> right click on your login -> properties -> type new password -> confirm password -> OK.
then disconnect your SQL and restart your system. then login SQL server 2008 with changed password in sql authentication mode.
Thanks :)
The answer: In the connection string, I just changed "User ID" to "uid" and "Password" to "pwd", and now it works. I now see "Connected successfully" in my SQL Server logs...
I'm trying to connect to a database this way:
(via http://localhost/test1.asp)
Form to database
<%
Set conn=Server.CreateObject("ADODB.Connection")
conn.Provider = "Microsoft.Jet.OLEDB.4.0"
conn.Open server.mappath("database.mdb")
%>
And it's not working!
I get this message:
An error occurred on the server when processing the URL. Please contact the system administrator.
If you are the system administrator please click here to find out more about this error.
If you are using IE, uncheck the "Show friendly HTTP error messages" under "Internet Options" -> "Advanced" and you should see a more descriptive error message that may help.
Reading your question I suspect you're relatively new to programming?
The link you pasted to localhost nly works on your computer (localhost means just that).
Read here about opening a connection to Access: http://www.webwiz.co.uk/kb/asp_tutorials/connecting_to_a_database.asp
Also, you might want to start with ASP.Net instead of the old asp. Just click the shiny button and everything will be installed on your computer: http://www.asp.net/downloads
Good luck,
GJ