ASP.NET ERROR : Keyword not supported: 'provider' - asp.net

My app fails at this line of code:
Dim objConnection As New SqlConnection(Application("ConnString"))
My connection string is:
"Server=testAITSQL;Database=SSCommerce;UID=PlanoWebApp;PWD=XXXXXXXX;"
I googled this problem and the solution for it was having a malformed connection string where the "provider" was being specified when it shouldn't have. Example conn string:
Provider=SQLOLEDB.1;Integrated Security=SSPI;DATABASE=APInquiry;SERVER=SqlServer
I'm not specifying the Provider so I think I have a different problem...???

Does your test server have the exact same configuration file as your development machine? I suspect the configuration file on your test machine may have a different set of values for ConnString than you are expecting.

Provider=xxxx is not a valid .net connection string token.
You are already implicitly specifying the provider by instantiating a SqlConnection.
Drop the provider pair and you will be golden.

maybe, for sh!7s and giggles, try Application("ConnString").tostring
You are connecting to a SQL Server, right?
My ConnString has the following options:
Server
Database
User ID
Password

Related

ConnectionString is incorrect in axapta

I want to connect to the other database using LoginProperty class. I did it in two different ways:
Create a DNS system object, using loginProperty class and connect to the DB. This way it works fine.
In the other way, i wants to creat a 'Connection String' and connect to the DB. In this way i am getting an error.
ODBC operation failed. Unable to logon to the database.
[Microsoft][ODBC Driver Manager] Data source name not found and there is no standard driver.
My Connection string is:
connectionString = "Driver={SQL Server Native Client 10.0}; Server=MSS2008-term\\\\SQLServer; Database=db; user ID=sa; Password=ABC.123";
loginProperty.setOther(connectionString);
conn = new ODBCConnection(loginProperty);
What is missing in the connection string?
Try using a raw string assignment (so no \ magic):
connectionString = #"Driver={SQL Server Native Client 10.0}; Server=MSS2008-term\SQLServer; Database=db; user ID=sa; Password=ABC.123";
Some others have problems, see ODBC connection to external data.
Maybe you can create the DSN by code, see What is the simplest, most maintainable way to create a SQL Server ODBC Data Source?
I notice you have Server and Database in your connection string where I use Data Source and Initial Catalog for some reason. You can do it like this, just changing/adding relevant parameters:
public str getConnectionString() {
System.Data.SqlClient.SqlConnectionStringBuilder dbConnectionStringBuilder;
dbConnectionStringBuilder = new System.Data.SqlClient.SqlConnectionStringBuilder();
dbConnectionStringBuilder.set_Item('Data Source', 'YourServer');
dbConnectionStringBuilder.set_Item('Initial Catalog', 'YourDatabase');
dbConnectionStringBuilder.set_Item('Integrated Security', true);
return dbConnectionStringBuilder.ToString();
}

Unable to use asp.net Web Site Administration Tool SQL connection error

I am working on IIS 7, SQL Express 2008.
I'm trying to use the Web Site Administration Tool to set up some users in a membership db. I have the tables set up but when I click on the security tab in the web app I get an exception "There is a problem with your selected data store..." the error i get is
"The following message may help in diagnosing the problem: Cannot open database "ticketinventory" requested by the login. The login failed. Login failed for user 'sa'"
The connection string I am using is "data source=kyrian-pc\sqlexpress;Initial Catalog=ticketinventory;Persist Security Info=True;User ID=sa;Password=******;"
(I know to not use sa for a connection string, this is just to get it to work initially and I have removed the password with ** )
I can log into sql with the sa username and password and query the membership tables. If I change the querystring to a fake user name I see the error message in the web app reflect that username so I know it is using the right connection string.
As far as I can tell this should be working but I am obviously missing something. Any ideas?
EDIT
It turns out the issue has something to do with my connection string itself. I created a test page with this code
using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString))
{
conn.Open();
conn.Close();
}
and this throws a login exception. For whatever reason my other connection string are being stored in the appSettings so there is some difference that I am now trying to work out.
Despite checking it 5 or 6 times I had the db name wrong in the connection string. Problem solved.
"The only infinite things are is the universe itself and the stupidity of man, and I'm not sure about the 1st one" - einstein

what is wrong with the sql lite connection string?

very new to sql lite,
I want to use it for a small project, get some overview, and try to implement but i got error while use following connection string?
Can some one please tell me what is wrong and what changes i need to do when i will set the path from web.config for sql lite connection string.
SQLiteConnection connection = new SQLiteConnection("D:\\Projects\\Apica MVC\\wizardDemo\\Apica.Signupweb.Presentation.MvcWeb\\App_Data\\SignUpWebDB");
i got an error.......
"Invalid ConnectionString format for parameter "D:\Projects\Apica MVC\wizardDemo\Apica.Signupweb.Presentation.MvcWeb\App_Data\SignUpWebDB""
There is no password set for string.
Your connection string isn't correctly formatted.
You're specifying the full path and filename of the database file, but you need to ensure that you include the Data source= part of the connection string in front of the actual database path and filename (also notice the semi-colon at the end of the connection string before the closing quote).
For example:
SQLiteConnection connection = new SQLiteConnection("Data Source=D:\\Projects\\Apica MVC\\wizardDemo\\Apica.Signupweb.Presentation.MvcWeb\\App_Data\\SignUpWebDB;");
There are more parameters that you can specify within a SQLite Connection string, see this link from the old System.Data.SQLite forums for further information. The complete documentation for the System.Data.SQLite package can be found at this page. The source code file (amongst others) contains the SQLite.NET.chm documentation file.

ASP.NET Connection String Error

I used this connection to run my SQL query, but it did not work and sent this error:
Keyword not supported: 'dsn'
This is my connection:
public static string CnnStr = #"Dsn=Server;uid=kity;app=Microsoft® Visual Studio® 2010;wsid=kity;database=Server;trusted_connection=Yes";
This connection works for me in my datalist, but for my behind code it gives me this error. II should say that I used ODBC connection to database.
create any .udl file
press enter on it
detect your data source and copy and paste you Connection String in the asp.net code
Try adding a value for providerName=System.Data.Odbc into the connection string.
Like this:
#"Dsn=Server;uid=kity;app=Microsoft® Visual Studio® 2010;wsid=kity;database=Server;trusted_connection=Yes;providerName=System.Data.Odbc;"
If that doesn't work, take a look at the same question in different situations:
Keyword not supported exception when attempting to use a connection string that points to a ODBC DSN
Keyword not supported: 'dsn'
Note: the "Keyword not supported: ..." error usually comes from an incorrectly formatted connection string.

What's wrong with this ASP connection string?

I'm at the end of my rope on this. It should be so simple.
I just need to know what's wrong with this connection string:
dbc.open ("Driver={SQL Server}; Data Source = ServerName; Initial Catalog = InitialDB; " "User ID = Username; Password = Password;")
I get this error when running that line:
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
I know ServerName is up and accepting connections, I know InitialDB exists, I know User ID and Password are valid for the database. What am I missing?
In notepad create file anyname.udl - let it be empty. After in explorer click it - you will get a dialog to create OLEDB connection string, select expected driver, and all connection param, ensure that "Allow saving password" = True. Press Ok.
Then again open file with notepad. Content is valid connection string
Try this...
dbc.open ("Provider=SQLOLEDB; Driver={SQL Server}; Data Source = ServerName; Initial Catalog = InitialDB; User ID = Username; Password = Password; Network Library=dbmssocn;")
As someone has already pointed out, udl is the best easiest way to create a conn string - here is a link that talks about it. https://web.archive.org/web/20210211044624/http://www.4guysfromrolla.com/webtech/070400-1.shtml
If you are using ADOdb you might want to try
"Provider=SQLNCLI10;Server=SERVER;Database=DATABASE;Uid=USERNAME;Pwd=PASSWORD"
for SQL Server 2008 Native Client or
"Provider=SQLNCLI;Server=SERVER;Database=DATABASE;Uid=USERNAME;Pwd=PASSWORD"
for SQL Server 2005 Native Client.
For ODBC, use
"Driver=SQL Server Native Client 10.0"
for SQL Server 2008 Native Client or
"Driver=SQL Native Client"
for SQL Server 2005 Native Client.
What's with the " " in the middle of the string?
Your connection string appears to be mixing ODBC and OLEDB. I would suggest visiting http://www.connectionstrings.com/ and finding the correct syntax for the desired provider.
Yours:
"Driver={SQL Server}; Data Source = ServerName; Initial Catalog = InitialDB; " "User ID = Username; Password = Password;"
ODBC:
"Driver={SQL Server};Server=ServerName;Database=InitialDB;Uid=Username;Pwd=Password;"
OLEDB:
"Provider=sqloledb;Data Source=ServerName;Initial Catalog=InitialDB;User Id=Username;Password=Password;"
Do you have visual studio?
Connect to the database server, and locate the database you want to connect to.
Right click, select properties. Your connection string to the db is right there.
Copy to wherever you want. -- Should be in web config, but you can paste it directly into code if you so desire.

Resources