OK. This is silly. Do I need a DSN on the server for a SQL connection?

  • Thread starter Hugh G. Johnson
  • Start date
H

Hugh G. Johnson

OK. I'm totally a Newb, so cut me some slack.

Here it goes... With all these high falutin features of asp.net do I still
need a dsn for the SQL database/server? Or is this enough to turn the lights
on?

<appSettings>

<add key="DBProvider" value="MSSQL" />
<add key="DBConn" value="data source=server;initial catalog=database;user
id=uid;password=pwd;persist security info=True;packet size=4096" />

</appSettings>

Thanks!

Hugh
 
G

Greg Burns

No you do not need a DSN. If you store your connection string info in your
web.config then you will need to later read it back out and use it.

<appSettings>
<add key="ConnectionString"
value="server=servername;Trusted_Connection=true;database=dbname;Application
Name=myappname"/>
</appSettings>

Dim cn As SqlConnection = New
SqlConnection(ConfigurationSettings.AppSettings("ConnectionString"))

With the above connection string, you would connect to SQL as the ASPNET
user. That user will need right to the database. Or you could supply a SQL
username and password as you were doing. If you also supply an Application
Name it is easier to debug using SQL Profiler. (Just ignore that if that
doesn't make sense to you).

HTH,
Greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top