Connecting with dsn - asp-classic

I have an application written in Classic ASP and VBScript. First it was developed for SQL Server 2000; I have upgraded this to SQL Server 2008. Previously I only need to define the DSN in the page like so:
DSN=""DSN="rrrr",UID="gggg"
But after upgrading to SQL Server 2008 it is not working. I need to define password attribute for this. (like this?)
DSN="DSN="rrrr",UID="gggg,PWD=xxxx""
Do we need to provide a password attribute or am I missing something?

You have quite a few different options to change your connection string to work with SQL Server 2008. If you are setting Trusted_Connection to true, then the password argument isn't used. You might have set up a 2008 INSTANCE, in which case, you need to use Server\Instance. It might be that simple.
From ConnectionStrings.com:
Standard Security
Server=myServerAddress;Database=myDataBase;User Id=myUsername;
Password=myPassword;
Trusted Connection
Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;
Connection to a SQL Server instance
Server=myServerName\myInstanceName;Database=myDataBase;User Id=myUsername;
Password=myPassword;
Connect via an IP address
Data Source=190.190.200.100,1433;Network Library=DBMSSOCN;
Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;

Related

Classic ASP connecting to localdb for SQL Server

Can anyone explain why this works
Conn.Open "Provider=SQLOLEDB;Server=tcp:myazurename.database.windows.net;Database=People;Uid=MyUid;Pwd=MyPwd;Encrypt=yes;"
and this doesn't
Conn.Open "Provider=SQLOLEDB;Server=(localdb)\v11.0;Database=People;Uid=MyUid;Pwd=MyPwd;Encrypt=yes;"
I copied my live azure database locally for dev work in Classic ASP and the error message is
Microsoft OLE DB Provider for SQL Server error '80004005'
[DBNETLIB][ConnectionOpen (Connect()).] SQL Server does not exist or access denied.
Azure SQL server version: 11.0.9231
Local SQL server version: 11.0.2318
I can connect using the same details on SQL Server Management Studio so its not a user permissions thing...
Under Security for the server, the user has public server role, the user mapping for the 'People' database is everything except db_denydatareader and db_denydatawriter.
I have also tried (localdb)\\v11.0 which doesn't make a difference.
Any ideas?
OK so I believe the answer is as follows: It doesn't like (LocalDb)\V11.0 it wants a proper instance name like you said in the first place. MACHINENAME\INSTANCENAME OR localhost\INSTANCENAME which I am using as this is going to be replicated for other devs. Also, you DONT NEED two back slashes! My problem is I somehow didn't have a local instance installed. Thanks or your help #Lankymart

web.config connection string to different database server

I have two conn strings in my web.config
The second of them connects to external database - the database is on different server than the current website.
Is it possible?
How do I write my connection string?
I have this now:
<add name="newConn" connectionString="server=www.somedomain.com;database=dbname;user id=dbuser;password=dbpass" providerName="MySql.Data.MySqlClient" />
But I'm getting error saying:
Access denied for user 'dbuser'#'currentdnsserver.com' (using password: YES)
Thanks
You have 2 questions:
Answers:
1. Absolutely.
2. You will need to write a connection string that use TCP/IP as the transport.
To debug this you should try connecting via the SQL Server Mgmt Studio using the credentials you are using in the conn string.
I assume you are using SQL Server, here is a typical connection string to a TCP/IP enabled DBMS using SQL Server authentication.
<add name="conn2" connectionString="Database=myDB;Server=serverNameOrIpAddress;uid=id;pwd=pwd;" providerName="System.Data.SqlClient"/>
The connection I wanted to establish was between different hosting server (one on Windows, another on Linux).
My hosting provider told me it's not possible to connecto from Windows .NET website to Linux MySQL db. Not sure why but not possible.
Would be possible on the same hosting they said.
Thank you for trying to help #T McKeown
Yes, you can connect to remote server and this is used alot.
The main thing that you should edit in your connection string is: Data Source.
Example:
Data Source=192.166.0.2;initial catalog=books;integrated security=False;user id=admin;password=!password1
Data Source: IP or URL of the computer you want to connect
Initial Catalog: Name of the Database you want to use
UserName and Password for the database user you want to use when you working with
the database are required.

Not able to change Connection String in SSIS DTSX package

I have 2 SSIS(DTSX) packages which is existing one made in SQL Server 2008,
Now I Have to migrate into SQL server 2012 But I am getting problem in changing connection string .
When I open in the Designer mode using SQL Server Data Tools. Previously it was pointing to another Remote Server Now I am not able to change the new server,
I am using the Provider as-Native OLEDB/Microsoft OLE DB Provider for SQL Server,
Server Name when I am giving automatically it's not coming in the dropdown list and when I check Test Connection it is giving Test Connection Succeeded but when I click Ok it is not changing?
Can anyone please help me on this to Resolve this problem
Thanks in advance
The connection might be being set by an expression. Check the expressions for that connection - you may have to change the expression that is being used to set the connection.

ASP.NET connection string for SQL Server 2012

I am having some trouble with a connection string between an ASP app sat on IIS and an existing SQL Server 2012 instance.
The current connection string that works is as follows:
Data Source=SERVER1;Initial Catalog=CORE;User
ID=testuser;Password=password;
MultipleActiveResultSets=true;Connection Timeout=200;pooling=false
The ODBC driver installed is SQL Server V 6.01.7601.17514. I then added the latest driver SQL Server Native Client 11 and tried adjusting the connection string in IIS with no luck.
I tried both ODBC and OLE DB strings from connectionstrings.com.
OLEDB
Provider=SQLNCLI11;Server=SERVER1;Database=CORE;Uid=testuser;Pwd=password;
ODBC
Driver={SQL Server Native Client 11.0};Server=SERVER1;Database=CORE;Uid=testuser;Pwd=password;
Each time I get a login prompt which I don't understand why the connection string is failing to supply these details with? What am I missing here?
Just having a look though some of the similar questions, some mentions named pipes which is enabled...
The first connection string is valid for the Net Framework Data Provider (the SqlClient classes), while the others are for the OleDb provider or ODBC provider.
Of course you should use the connection string that your provider understand.
If, in your code, you use the SqlClient classes (SqlConnection, SqlCommand) then you need to use the first connection string, if you use OleDbConnection or ODBCConnection you should use the others
See connectionstrings.com
I've always done it this way:
Data Source=;Initial Catalog=;UID=;PWD=;
I also recommend you put the connection string in a config file for easy editing like this: http://www.connectionstrings.com/Articles/Show/store-connection-string-in-web-config

working with sql server 2008

I am not used to work with SQL Server(usually I just use express). I run it on windows server 2008, iis7.
I have attached the database to my sql server. I made a web site in iis7 but I get this error message.
Cannot open database "Phaeton.mdf" requested by the login. The login failed.
Login failed for user 'NT AUTHORITY\NETWORK SERVICE'.
Connectionstring I use
<add key="PhaetonConnectionString" value="Data Source=.;Initial Catalog=Phaeton.mdf;Integrated Security=True"/>
Thanks
Since you are using Integrated Security the SQL connection will use the windows identity which is passed from ASP.NET.
You can either change your security to mixed-mode which will involve removing the integrated security. Or use impersonation (check IIS and your web.config) and grant that user access to the database.
Hope that helps
You need to configure your application in IIS to turn off anonymous access and turn on Windows authentication(If yoy want to use integrated security).
Access SQL Server Using Windows Integrated Security
The other way, you can use a connection string with user/password ... with the appropriate login
Problem was that the database I tried to attach was sql express
The problem is here:
Initial Catalog=Phaeton.mdf
In SQL Server Express, you can attach a filename as a local database. That's not how it works on a production SQL Server. In non-Express versions you attach a database permanently, which it looks like you've already done, and you give it a logical name, which is not the same as the primary file name.
I would guess that if the file name was "Phaeton.mdf" then you probably named the database "Phaeton". In which case that part of the connection string should simply be:
Initial Catalog=Phaeton
If that's not the right name, you can get a list of database names from the server using the following script:
USE master;
SELECT name FROM sys.databases

Resources