Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keyword Not Supported: dsn 1

Status
Not open for further replies.

hrhadin

Programmer
Oct 7, 2003
16
0
0
US
I have the following code in the page_load event of page Default.aspx:

Imports System.Data
Imports System.Data.SqlClient

Partial Class _Default

Protected Sub page_load(ByVal sender As Object, ByVal e As System.EventArgs)

If Not IsPostBack Then
Dim conn As New SqlConnection

conn.ConnectionString = "Dsn=Wic;uid=sa;pwd=flatfive"
End If
End Sub
End Class

When I run this code it gives me the error stated in the Subject.

The Dsn is valid. I use it to connect to SQL server often.
What am I doing wrong?
 
As you say in the title, the odbc might not support dsn connection. Use an other
 
Thanks for your help TipGiver. The ConnectionString.com provided me with correct format for my string.
 
Ideally, you should keep the connection string in your web.config file. Place it in the appSettings section like this:
Code:
	<appSettings>
		<add key="myConnectionString" value="enter the string here"/>
	</appSettings>
and then retrieve it like this:
Code:
Dim myString As String = ConfigurationManager.AppSettings("myConnectionString")


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top