1

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.

Andrew Kozak
  • 1,631
  • 2
  • 22
  • 35
Katy J
  • 205
  • 1
  • 7
  • 16

2 Answers2

0

create any .udl file

press enter on it

detect your data source and copy and paste you Connection String in the asp.net code

Royi Namir
  • 144,742
  • 138
  • 468
  • 792
  • I do this and this connection string is the exact that copy of string but i dont know why it does not work,it works when i use in sqldatasource but when i use it as a code in code behind it shows me that error – Katy J Oct 15 '11 at 11:05
0

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.

Community
  • 1
  • 1
Gibron
  • 1,350
  • 1
  • 9
  • 28