469,358 Members | 1,628 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,358 developers. It's quick & easy.

Q: using DSN

Hello,
I have the following lines to read connection string from web.config;

string cStr = ConfigurationSettings.AppSettings["connectionString"];
SqlConnection sqlConn = new SqlConnection(cStr);
this.sqlConnection1.ConnectionString = cStr;

How can replace this with a DSN (ODBC connection) I defined in my current
machine?
Thanks,

Nov 19 '05 #1
13 3399
Jim,

have a look at:
http://www.connectionstrings.com/

Regards

Daniel Walzenbach

"JIM.H." <JI**@discussions.microsoft.com> schrieb im Newsbeitrag
news:8D**********************************@microsof t.com...
Hello,
I have the following lines to read connection string from web.config;

string cStr = ConfigurationSettings.AppSettings["connectionString"];
SqlConnection sqlConn = new SqlConnection(cStr);
this.sqlConnection1.ConnectionString = cStr;

How can replace this with a DSN (ODBC connection) I defined in my current
machine?
Thanks,

Nov 19 '05 #2
Hi Daniel,
Thanks you for your reply. I was checking that site I did not really see
how I could use a DSN called myDSN for SQL server connection in there. Can
you give me specific example?
Thanks,
"Daniel Walzenbach" wrote:
Jim,

have a look at:
http://www.connectionstrings.com/

Regards

Daniel Walzenbach

"JIM.H." <JI**@discussions.microsoft.com> schrieb im Newsbeitrag
news:8D**********************************@microsof t.com...
Hello,
I have the following lines to read connection string from web.config;

string cStr = ConfigurationSettings.AppSettings["connectionString"];
SqlConnection sqlConn = new SqlConnection(cStr);
this.sqlConnection1.ConnectionString = cStr;

How can replace this with a DSN (ODBC connection) I defined in my current
machine?
Thanks,


Nov 19 '05 #3
Jim,

have you tried those entries?

a.. DSN:

"DSN=myDsn;Uid=username;Pwd=;"
a.. File DSN:

"FILEDSN=c:\myData.dsn;Uid=username;Pwd=;"
Daniel
"JIM.H." <JI**@discussions.microsoft.com> schrieb im Newsbeitrag
news:5E**********************************@microsof t.com...
Hi Daniel,
Thanks you for your reply. I was checking that site I did not really see
how I could use a DSN called myDSN for SQL server connection in there. Can
you give me specific example?
Thanks,
"Daniel Walzenbach" wrote:
Jim,

have a look at:
http://www.connectionstrings.com/

Regards

Daniel Walzenbach

"JIM.H." <JI**@discussions.microsoft.com> schrieb im Newsbeitrag
news:8D**********************************@microsof t.com...
> Hello,
> I have the following lines to read connection string from web.config;
>
> string cStr = ConfigurationSettings.AppSettings["connectionString"];
> SqlConnection sqlConn = new SqlConnection(cStr);
> this.sqlConnection1.ConnectionString = cStr;
>
> How can replace this with a DSN (ODBC connection) I defined in my
> current
> machine?
> Thanks,
>


Nov 19 '05 #4
Hi Dear JIM.H,

This is the sample where you give all your connection string values inside
the asp.net file (ie. for example: in code behind)

But in your case You have to give

either

"DSN=mySystemDSN;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"

or

"FILEDSN=c:\somepath\mydb.dsn;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"

in you web.config in <appSettings></appSettings> section like below

<configuration>
<appSettings>
<add key="pubsDSN" value="DSN=mySystemDSN;Uid=myUsername;Pwd=myPasswo rd"
/>
</appSettings>
</configuration>

OR

<configuration>
<appSettings>
<add key="pubsFileDSN"
value="FILEDSN=c:\somepath\mydb.dsn;Uid=myUsername ;Pwd=myPassword"/>
</appSettings>
</configuration>

and

in your code behind to access the web.config file DSN/FileDSN

Dim dsn As String = ConfigurationSettings.AppSettings("pubsDSN")
or
Dim dsn As String = ConfigurationSettings.AppSettings("pubsFileDSN")
ODBC DSN
=======
Using an ODBC DSN (Data Source Name) is a two step process.

1) You must first create the DSN via the "ODBC Data Source Administrator"
program found in your computer's Control Panel (or Administrative Tools menu
in Windows 2000). Make sure to create a SYSTEM DSN (not a USER DSN) when
using ASP(I think same thing holds good for ASP.NET).

2) Then use the following connection string - with your own DSN
name of course.

DSN
====
oConn.Open "DSN=mySystemDSN;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"

File DSN
======
oConn.Open "FILEDSN=c:\somepath\mydb.dsn;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"

Note:
====
The problem with DSN is that Users can (and will) modify or delete them by
mistake, then your program won't work so well. So it's better to use a
DSN-Less or OLE DB Provider connection string - with a Trusted Connection if
possible!

About ODBC data sources
================
http://msdn.microsoft.com/library/de...ataSources.asp
Login System (ASP.NET)
================
http://www.codeproject.com/Purgatory/Login_System.asp

For Anything & Everything, Please Let Me Know

Bye
Venkat_KL
Nov 19 '05 #5
Other than a DSN is not an property of SqlConnection,
and therefore you cannot use DSN with a SqlConnection,

(Click the "Read more" icon under "Data Shape", at http://www.connectionstrings.com/
and then click "All SqlConnection connectionstring properties", so that
the table of properties for the ADO.NET SqlConnection object opens.)

....the question I would ask is :

why would you want to use an OLEDB for ODBC provider
rather than the native SQL provider for SQL Server ?

Typically, this will result in slower performance, because you'd
have to go through an additional layer from OLEDB to ODBC.

You can use the OLEDB driver directly or, far more recommended, use the native
SQLConnection ADO.NET object, which uses native SQL Server methods to do
the job quite a bit more efficiently than either OLEDB or ODBC.


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:5E**********************************@microsof t.com...
Hi Daniel,
Thanks you for your reply. I was checking that site I did not really see
how I could use a DSN called myDSN for SQL server connection in there. Can
you give me specific example?
Thanks,
"Daniel Walzenbach" wrote:
Jim,

have a look at:
http://www.connectionstrings.com/

Regards

Daniel Walzenbach

"JIM.H." <JI**@discussions.microsoft.com> schrieb im Newsbeitrag
news:8D**********************************@microsof t.com...
> Hello,
> I have the following lines to read connection string from web.config;
>
> string cStr = ConfigurationSettings.AppSettings["connectionString"];
> SqlConnection sqlConn = new SqlConnection(cStr);
> this.sqlConnection1.ConnectionString = cStr;
>
> How can replace this with a DSN (ODBC connection) I defined in my current
> machine?
> Thanks,

Nov 19 '05 #6
Hi Venkat_KL,
Thank you very much for all this great help. Since I am using
“this.sqlConnection1.ConnectionString” in many places such as “SqlCommand
sqlCmd = new SqlCommand(sqlStr, connStr);” When I read my DSN from web.config
with the example you gave, how should I use it instead of
“this.sqlConnection1.ConnectionString” in my code? Will this “SqlCommand
sqlCmd = new SqlCommand(sqlStr, myDSN);” work? I am new in asp.net and do not
know all these details.
Thanks,


"Venkat_KL" wrote:
Hi Dear JIM.H,

This is the sample where you give all your connection string values inside
the asp.net file (ie. for example: in code behind)

But in your case You have to give

either

"DSN=mySystemDSN;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"

or

"FILEDSN=c:\somepath\mydb.dsn;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"

in you web.config in <appSettings></appSettings> section like below

<configuration>
<appSettings>
<add key="pubsDSN" value="DSN=mySystemDSN;Uid=myUsername;Pwd=myPasswo rd"
/>
</appSettings>
</configuration>

OR

<configuration>
<appSettings>
<add key="pubsFileDSN"
value="FILEDSN=c:\somepath\mydb.dsn;Uid=myUsername ;Pwd=myPassword"/>
</appSettings>
</configuration>

and

in your code behind to access the web.config file DSN/FileDSN

Dim dsn As String = ConfigurationSettings.AppSettings("pubsDSN")
or
Dim dsn As String = ConfigurationSettings.AppSettings("pubsFileDSN")
ODBC DSN
=======
Using an ODBC DSN (Data Source Name) is a two step process.

1) You must first create the DSN via the "ODBC Data Source Administrator"
program found in your computer's Control Panel (or Administrative Tools menu
in Windows 2000). Make sure to create a SYSTEM DSN (not a USER DSN) when
using ASP(I think same thing holds good for ASP.NET).

2) Then use the following connection string - with your own DSN
name of course.

DSN
====
oConn.Open "DSN=mySystemDSN;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"

File DSN
======
oConn.Open "FILEDSN=c:\somepath\mydb.dsn;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"

Note:
====
The problem with DSN is that Users can (and will) modify or delete them by
mistake, then your program won't work so well. So it's better to use a
DSN-Less or OLE DB Provider connection string - with a Trusted Connection if
possible!

About ODBC data sources
================
http://msdn.microsoft.com/library/de...ataSources.asp
Login System (ASP.NET)
================
http://www.codeproject.com/Purgatory/Login_System.asp

For Anything & Everything, Please Let Me Know

Bye
Venkat_KL

Nov 19 '05 #7
The only problem with that is that he didn't want to use <appSettings>.

;-)


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Venkat_KL" <Ve******@discussions.microsoft.com> wrote in message
news:D9**********************************@microsof t.com...
Hi Dear JIM.H,

This is the sample where you give all your connection string values inside
the asp.net file (ie. for example: in code behind)

But in your case You have to give

either

"DSN=mySystemDSN;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"

or

"FILEDSN=c:\somepath\mydb.dsn;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"

in you web.config in <appSettings></appSettings> section like below

<configuration>
<appSettings>
<add key="pubsDSN" value="DSN=mySystemDSN;Uid=myUsername;Pwd=myPasswo rd"
/>
</appSettings>
</configuration>

OR

<configuration>
<appSettings>
<add key="pubsFileDSN"
value="FILEDSN=c:\somepath\mydb.dsn;Uid=myUsername ;Pwd=myPassword"/>
</appSettings>
</configuration>

and

in your code behind to access the web.config file DSN/FileDSN

Dim dsn As String = ConfigurationSettings.AppSettings("pubsDSN")
or
Dim dsn As String = ConfigurationSettings.AppSettings("pubsFileDSN")
ODBC DSN
=======
Using an ODBC DSN (Data Source Name) is a two step process.

1) You must first create the DSN via the "ODBC Data Source Administrator"
program found in your computer's Control Panel (or Administrative Tools menu
in Windows 2000). Make sure to create a SYSTEM DSN (not a USER DSN) when
using ASP(I think same thing holds good for ASP.NET).

2) Then use the following connection string - with your own DSN
name of course.

DSN
====
oConn.Open "DSN=mySystemDSN;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"

File DSN
======
oConn.Open "FILEDSN=c:\somepath\mydb.dsn;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"

Note:
====
The problem with DSN is that Users can (and will) modify or delete them by
mistake, then your program won't work so well. So it's better to use a
DSN-Less or OLE DB Provider connection string - with a Trusted Connection if
possible!

About ODBC data sources
================
http://msdn.microsoft.com/library/de...ataSources.asp
Login System (ASP.NET)
================
http://www.codeproject.com/Purgatory/Login_System.asp

For Anything & Everything, Please Let Me Know

Bye
Venkat_KL

Nov 19 '05 #8
re:
Will this "SqlCommand sqlCmd = new SqlCommand(sqlStr, myDSN);" work?
No, it won't. See my earlier reply.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:28**********************************@microsof t.com... Hi Venkat_KL,
Thank you very much for all this great help. Since I am using
"this.sqlConnection1.ConnectionString" in many places such as "SqlCommand
sqlCmd = new SqlCommand(sqlStr, connStr);" When I read my DSN from web.config
with the example you gave, how should I use it instead of
"this.sqlConnection1.ConnectionString" in my code? Will this "SqlCommand
sqlCmd = new SqlCommand(sqlStr, myDSN);" work? I am new in asp.net and do not
know all these details.
Thanks,


"Venkat_KL" wrote:
Hi Dear JIM.H,

This is the sample where you give all your connection string values inside
the asp.net file (ie. for example: in code behind)

But in your case You have to give

either

"DSN=mySystemDSN;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"

or

"FILEDSN=c:\somepath\mydb.dsn;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"

in you web.config in <appSettings></appSettings> section like below

<configuration>
<appSettings>
<add key="pubsDSN" value="DSN=mySystemDSN;Uid=myUsername;Pwd=myPasswo rd"
/>
</appSettings>
</configuration>

OR

<configuration>
<appSettings>
<add key="pubsFileDSN"
value="FILEDSN=c:\somepath\mydb.dsn;Uid=myUsername ;Pwd=myPassword"/>
</appSettings>
</configuration>

and

in your code behind to access the web.config file DSN/FileDSN

Dim dsn As String = ConfigurationSettings.AppSettings("pubsDSN")
or
Dim dsn As String = ConfigurationSettings.AppSettings("pubsFileDSN")
ODBC DSN
=======
Using an ODBC DSN (Data Source Name) is a two step process.

1) You must first create the DSN via the "ODBC Data Source Administrator"
program found in your computer's Control Panel (or Administrative Tools menu
in Windows 2000). Make sure to create a SYSTEM DSN (not a USER DSN) when
using ASP(I think same thing holds good for ASP.NET).

2) Then use the following connection string - with your own DSN
name of course.

DSN
====
oConn.Open "DSN=mySystemDSN;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"

File DSN
======
oConn.Open "FILEDSN=c:\somepath\mydb.dsn;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"

Note:
====
The problem with DSN is that Users can (and will) modify or delete them by
mistake, then your program won't work so well. So it's better to use a
DSN-Less or OLE DB Provider connection string - with a Trusted Connection if
possible!

About ODBC data sources
================
http://msdn.microsoft.com/library/de...ataSources.asp
Login System (ASP.NET)
================
http://www.codeproject.com/Purgatory/Login_System.asp

For Anything & Everything, Please Let Me Know

Bye
Venkat_KL

Nov 19 '05 #9
Hi Juan,
Thanks for the reply. Ok. I understand it might be little bit slow through
DSN, once I create DSN how do I use it in the code? Is there any way I can
create SQLCommand through DSN.
Thanks,

"Juan T. Llibre" wrote:
re:
Will this "SqlCommand sqlCmd = new SqlCommand(sqlStr, myDSN);" work?


No, it won't. See my earlier reply.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:28**********************************@microsof t.com...
Hi Venkat_KL,
Thank you very much for all this great help. Since I am using
"this.sqlConnection1.ConnectionString" in many places such as "SqlCommand
sqlCmd = new SqlCommand(sqlStr, connStr);" When I read my DSN from web.config
with the example you gave, how should I use it instead of
"this.sqlConnection1.ConnectionString" in my code? Will this "SqlCommand
sqlCmd = new SqlCommand(sqlStr, myDSN);" work? I am new in asp.net and do not
know all these details.
Thanks,


"Venkat_KL" wrote:
Hi Dear JIM.H,

This is the sample where you give all your connection string values inside
the asp.net file (ie. for example: in code behind)

But in your case You have to give

either

"DSN=mySystemDSN;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"

or

"FILEDSN=c:\somepath\mydb.dsn;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"

in you web.config in <appSettings></appSettings> section like below

<configuration>
<appSettings>
<add key="pubsDSN" value="DSN=mySystemDSN;Uid=myUsername;Pwd=myPasswo rd"
/>
</appSettings>
</configuration>

OR

<configuration>
<appSettings>
<add key="pubsFileDSN"
value="FILEDSN=c:\somepath\mydb.dsn;Uid=myUsername ;Pwd=myPassword"/>
</appSettings>
</configuration>

and

in your code behind to access the web.config file DSN/FileDSN

Dim dsn As String = ConfigurationSettings.AppSettings("pubsDSN")
or
Dim dsn As String = ConfigurationSettings.AppSettings("pubsFileDSN")
ODBC DSN
=======
Using an ODBC DSN (Data Source Name) is a two step process.

1) You must first create the DSN via the "ODBC Data Source Administrator"
program found in your computer's Control Panel (or Administrative Tools menu
in Windows 2000). Make sure to create a SYSTEM DSN (not a USER DSN) when
using ASP(I think same thing holds good for ASP.NET).

2) Then use the following connection string - with your own DSN
name of course.

DSN
====
oConn.Open "DSN=mySystemDSN;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"

File DSN
======
oConn.Open "FILEDSN=c:\somepath\mydb.dsn;" & _
"Uid=myUsername;" & _
"Pwd=myPassword"

Note:
====
The problem with DSN is that Users can (and will) modify or delete them by
mistake, then your program won't work so well. So it's better to use a
DSN-Less or OLE DB Provider connection string - with a Trusted Connection if
possible!

About ODBC data sources
================
http://msdn.microsoft.com/library/de...ataSources.asp
Login System (ASP.NET)
================
http://www.codeproject.com/Purgatory/Login_System.asp

For Anything & Everything, Please Let Me Know

Bye
Venkat_KL


Nov 19 '05 #10
re:
once I create DSN how do I use it in the code?
I don't think you can use it, Jim.

There's no way for the DSN or FILEDSN parameters to be inserted
into a SQLConnection or a SQLCommand object, at least as far as I know.

That is why when you asked earlier :Will this "SqlCommand sqlCmd = new SqlCommand(sqlStr, myDSN);" work?
I replied : "No, it won't."

And, in the other thread you started on the same subject, I said :
Other than a DSN is not an property of SqlConnection,
and therefore you cannot use DSN with a SqlConnection
I just don't think that it can be done.
If you learn a way to do that, please post it and I will change my opinion.


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:EB**********************************@microsof t.com... Hi Juan,
Thanks for the reply. Ok. I understand it might be little bit slow through
DSN, once I create DSN how do I use it in the code? Is there any way I can
create SQLCommand through DSN.
Thanks,

"Juan T. Llibre" wrote:
re:
>Will this "SqlCommand sqlCmd = new SqlCommand(sqlStr, myDSN);" work?


No, it won't. See my earlier reply.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:28**********************************@microsof t.com...
> Hi Venkat_KL,
> Thank you very much for all this great help. Since I am using
> "this.sqlConnection1.ConnectionString" in many places such as "SqlCommand
> sqlCmd = new SqlCommand(sqlStr, connStr);" When I read my DSN from web.config
> with the example you gave, how should I use it instead of
> "this.sqlConnection1.ConnectionString" in my code? Will this "SqlCommand
> sqlCmd = new SqlCommand(sqlStr, myDSN);" work? I am new in asp.net and do not
> know all these details.
> Thanks,
>
>
>
>
> "Venkat_KL" wrote:
>
>> Hi Dear JIM.H,
>>
>> This is the sample where you give all your connection string values inside
>> the asp.net file (ie. for example: in code behind)
>>
>> But in your case You have to give
>>
>> either
>>
>> "DSN=mySystemDSN;" & _
>> "Uid=myUsername;" & _
>> "Pwd=myPassword"
>>
>> or
>>
>> "FILEDSN=c:\somepath\mydb.dsn;" & _
>> "Uid=myUsername;" & _
>> "Pwd=myPassword"
>>
>> in you web.config in <appSettings></appSettings> section like below
>>
>> <configuration>
>> <appSettings>
>> <add key="pubsDSN" value="DSN=mySystemDSN;Uid=myUsername;Pwd=myPasswo rd"
>> />
>> </appSettings>
>> </configuration>
>>
>> OR
>>
>> <configuration>
>> <appSettings>
>> <add key="pubsFileDSN"
>> value="FILEDSN=c:\somepath\mydb.dsn;Uid=myUsername ;Pwd=myPassword"/>
>> </appSettings>
>> </configuration>
>>
>> and
>>
>> in your code behind to access the web.config file DSN/FileDSN
>>
>> Dim dsn As String = ConfigurationSettings.AppSettings("pubsDSN")
>> or
>> Dim dsn As String = ConfigurationSettings.AppSettings("pubsFileDSN")
>>
>>
>> ODBC DSN
>> =======
>> Using an ODBC DSN (Data Source Name) is a two step process.
>>
>> 1) You must first create the DSN via the "ODBC Data Source Administrator"
>> program found in your computer's Control Panel (or Administrative Tools menu
>> in Windows 2000). Make sure to create a SYSTEM DSN (not a USER DSN) when
>> using ASP(I think same thing holds good for ASP.NET).
>>
>> 2) Then use the following connection string - with your own DSN
>> name of course.
>>
>> DSN
>> ====
>> oConn.Open "DSN=mySystemDSN;" & _
>> "Uid=myUsername;" & _
>> "Pwd=myPassword"
>>
>> File DSN
>> ======
>> oConn.Open "FILEDSN=c:\somepath\mydb.dsn;" & _
>> "Uid=myUsername;" & _
>> "Pwd=myPassword"
>>
>> Note:
>> ====
>> The problem with DSN is that Users can (and will) modify or delete them by
>> mistake, then your program won't work so well. So it's better to use a
>> DSN-Less or OLE DB Provider connection string - with a Trusted Connection if
>> possible!
>>
>>
>>
>> About ODBC data sources
>> ================
>> http://msdn.microsoft.com/library/de...ataSources.asp
>>
>>
>> Login System (ASP.NET)
>> ================
>> http://www.codeproject.com/Purgatory/Login_System.asp
>>
>> For Anything & Everything, Please Let Me Know
>>
>> Bye
>> Venkat_KL


Nov 19 '05 #11
Hi Juan,

I see your point, I am not just understanding if DSN definition is possible
in APS.Net, where and how I will use it?

Here is a connection string I can use it ASP;
Set objADODBConn = CreateObject("ADODB.Connection")
strConn="DSN=" & MyODBC & ";UID=" & MyUsername & ";PWD=" & MyPassword & ";"
objADODBConn.Open(strConn)

I could not believe that Microsoft does not allow this kind of thing in
ASP.Net for SQL connection. DSN is still using native SQL Server driver in
the system.
However thank you very much for your time.
"Juan T. Llibre" wrote:
re:
once I create DSN how do I use it in the code?


I don't think you can use it, Jim.

There's no way for the DSN or FILEDSN parameters to be inserted
into a SQLConnection or a SQLCommand object, at least as far as I know.

That is why when you asked earlier :
Will this "SqlCommand sqlCmd = new SqlCommand(sqlStr, myDSN);" work?


I replied : "No, it won't."

And, in the other thread you started on the same subject, I said :
Other than a DSN is not an property of SqlConnection,
and therefore you cannot use DSN with a SqlConnection


I just don't think that it can be done.
If you learn a way to do that, please post it and I will change my opinion.


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:EB**********************************@microsof t.com...
Hi Juan,
Thanks for the reply. Ok. I understand it might be little bit slow through
DSN, once I create DSN how do I use it in the code? Is there any way I can
create SQLCommand through DSN.
Thanks,

"Juan T. Llibre" wrote:
re:
>Will this "SqlCommand sqlCmd = new SqlCommand(sqlStr, myDSN);" work?

No, it won't. See my earlier reply.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:28**********************************@microsof t.com...
> Hi Venkat_KL,
> Thank you very much for all this great help. Since I am using
> "this.sqlConnection1.ConnectionString" in many places such as "SqlCommand
> sqlCmd = new SqlCommand(sqlStr, connStr);" When I read my DSN from web.config
> with the example you gave, how should I use it instead of
> "this.sqlConnection1.ConnectionString" in my code? Will this "SqlCommand
> sqlCmd = new SqlCommand(sqlStr, myDSN);" work? I am new in asp.net and do not
> know all these details.
> Thanks,
>
>
>
>
> "Venkat_KL" wrote:
>
>> Hi Dear JIM.H,
>>
>> This is the sample where you give all your connection string values inside
>> the asp.net file (ie. for example: in code behind)
>>
>> But in your case You have to give
>>
>> either
>>
>> "DSN=mySystemDSN;" & _
>> "Uid=myUsername;" & _
>> "Pwd=myPassword"
>>
>> or
>>
>> "FILEDSN=c:\somepath\mydb.dsn;" & _
>> "Uid=myUsername;" & _
>> "Pwd=myPassword"
>>
>> in you web.config in <appSettings></appSettings> section like below
>>
>> <configuration>
>> <appSettings>
>> <add key="pubsDSN" value="DSN=mySystemDSN;Uid=myUsername;Pwd=myPasswo rd"
>> />
>> </appSettings>
>> </configuration>
>>
>> OR
>>
>> <configuration>
>> <appSettings>
>> <add key="pubsFileDSN"
>> value="FILEDSN=c:\somepath\mydb.dsn;Uid=myUsername ;Pwd=myPassword"/>
>> </appSettings>
>> </configuration>
>>
>> and
>>
>> in your code behind to access the web.config file DSN/FileDSN
>>
>> Dim dsn As String = ConfigurationSettings.AppSettings("pubsDSN")
>> or
>> Dim dsn As String = ConfigurationSettings.AppSettings("pubsFileDSN")
>>
>>
>> ODBC DSN
>> =======
>> Using an ODBC DSN (Data Source Name) is a two step process.
>>
>> 1) You must first create the DSN via the "ODBC Data Source Administrator"
>> program found in your computer's Control Panel (or Administrative Tools menu
>> in Windows 2000). Make sure to create a SYSTEM DSN (not a USER DSN) when
>> using ASP(I think same thing holds good for ASP.NET).
>>
>> 2) Then use the following connection string - with your own DSN
>> name of course.
>>
>> DSN
>> ====
>> oConn.Open "DSN=mySystemDSN;" & _
>> "Uid=myUsername;" & _
>> "Pwd=myPassword"
>>
>> File DSN
>> ======
>> oConn.Open "FILEDSN=c:\somepath\mydb.dsn;" & _
>> "Uid=myUsername;" & _
>> "Pwd=myPassword"
>>
>> Note:
>> ====
>> The problem with DSN is that Users can (and will) modify or delete them by
>> mistake, then your program won't work so well. So it's better to use a
>> DSN-Less or OLE DB Provider connection string - with a Trusted Connection if
>> possible!
>>
>>
>>
>> About ODBC data sources
>> ================
>> http://msdn.microsoft.com/library/de...ataSources.asp
>>
>>
>> Login System (ASP.NET)
>> ================
>> http://www.codeproject.com/Purgatory/Login_System.asp
>>
>> For Anything & Everything, Please Let Me Know
>>
>> Bye
>> Venkat_KL


Nov 19 '05 #12
You are trying to use ADO in ASP.NET.

For a zillion reasons that is not good.

re:
I could not believe that Microsoft does not allow
this kind of thing in ASP.Net for SQL connection.
Believe it.

Why would Microsoft include as an option something
which buries performance for web applications ?

Take a few minutes to see this ADO.NET presentation :
http://www.microsoft.com/seminar/sha...7/manifest.xml

Also, read the links on this page :
http://msdn.microsoft.com/library/de...withadonet.asp

Don't beat your head against the wall by trying to use ADO in ASP.NET.
You're only going to hurt yourself.


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:AE**********************************@microsof t.com... Hi Juan,

I see your point, I am not just understanding if DSN definition is possible
in APS.Net, where and how I will use it?

Here is a connection string I can use it ASP;
Set objADODBConn = CreateObject("ADODB.Connection")
strConn="DSN=" & MyODBC & ";UID=" & MyUsername & ";PWD=" & MyPassword & ";"
objADODBConn.Open(strConn)

I could not believe that Microsoft does not allow this kind of thing in
ASP.Net for SQL connection. DSN is still using native SQL Server driver in
the system.
However thank you very much for your time.
"Juan T. Llibre" wrote:
re:
> once I create DSN how do I use it in the code?


I don't think you can use it, Jim.

There's no way for the DSN or FILEDSN parameters to be inserted
into a SQLConnection or a SQLCommand object, at least as far as I know.

That is why when you asked earlier :
>Will this "SqlCommand sqlCmd = new SqlCommand(sqlStr, myDSN);" work?


I replied : "No, it won't."

And, in the other thread you started on the same subject, I said :
>Other than a DSN is not an property of SqlConnection,
>and therefore you cannot use DSN with a SqlConnection


I just don't think that it can be done.
If you learn a way to do that, please post it and I will change my opinion.


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:EB**********************************@microsof t.com...
> Hi Juan,
> Thanks for the reply. Ok. I understand it might be little bit slow through
> DSN, once I create DSN how do I use it in the code? Is there any way I can
> create SQLCommand through DSN.
> Thanks,
>
> "Juan T. Llibre" wrote:
>
>> re:
>> >Will this "SqlCommand sqlCmd = new SqlCommand(sqlStr, myDSN);" work?
>>
>> No, it won't. See my earlier reply.
>>
>>
>>
>> Juan T. Llibre, ASP.NET MVP
>> ASP.NET FAQ : http://asp.net.do/faq/
>> ASPNETFAQ.COM : http://www.aspnetfaq.com/
>> Foros de ASP.NET en Español : http://asp.net.do/foros/
>> ======================================
>> "JIM.H." <JI**@discussions.microsoft.com> wrote in message
>> news:28**********************************@microsof t.com...
>> > Hi Venkat_KL,
>> > Thank you very much for all this great help. Since I am using
>> > "this.sqlConnection1.ConnectionString" in many places such as "SqlCommand
>> > sqlCmd = new SqlCommand(sqlStr, connStr);" When I read my DSN from web.config
>> > with the example you gave, how should I use it instead of
>> > "this.sqlConnection1.ConnectionString" in my code? Will this "SqlCommand
>> > sqlCmd = new SqlCommand(sqlStr, myDSN);" work? I am new in asp.net and do not
>> > know all these details.
>> > Thanks,
>> >
>> >
>> >
>> >
>> > "Venkat_KL" wrote:
>> >
>> >> Hi Dear JIM.H,
>> >>
>> >> This is the sample where you give all your connection string values inside
>> >> the asp.net file (ie. for example: in code behind)
>> >>
>> >> But in your case You have to give
>> >>
>> >> either
>> >>
>> >> "DSN=mySystemDSN;" & _
>> >> "Uid=myUsername;" & _
>> >> "Pwd=myPassword"
>> >>
>> >> or
>> >>
>> >> "FILEDSN=c:\somepath\mydb.dsn;" & _
>> >> "Uid=myUsername;" & _
>> >> "Pwd=myPassword"
>> >>
>> >> in you web.config in <appSettings></appSettings> section like below
>> >>
>> >> <configuration>
>> >> <appSettings>
>> >> <add key="pubsDSN" value="DSN=mySystemDSN;Uid=myUsername;Pwd=myPasswo rd"
>> >> />
>> >> </appSettings>
>> >> </configuration>
>> >>
>> >> OR
>> >>
>> >> <configuration>
>> >> <appSettings>
>> >> <add key="pubsFileDSN"
>> >> value="FILEDSN=c:\somepath\mydb.dsn;Uid=myUsername ;Pwd=myPassword"/>
>> >> </appSettings>
>> >> </configuration>
>> >>
>> >> and
>> >>
>> >> in your code behind to access the web.config file DSN/FileDSN
>> >>
>> >> Dim dsn As String = ConfigurationSettings.AppSettings("pubsDSN")
>> >> or
>> >> Dim dsn As String = ConfigurationSettings.AppSettings("pubsFileDSN")
>> >>
>> >>
>> >> ODBC DSN
>> >> =======
>> >> Using an ODBC DSN (Data Source Name) is a two step process.
>> >>
>> >> 1) You must first create the DSN via the "ODBC Data Source Administrator"
>> >> program found in your computer's Control Panel (or Administrative Tools menu
>> >> in Windows 2000). Make sure to create a SYSTEM DSN (not a USER DSN) when
>> >> using ASP(I think same thing holds good for ASP.NET).
>> >>
>> >> 2) Then use the following connection string - with your own DSN
>> >> name of course.
>> >>
>> >> DSN
>> >> ====
>> >> oConn.Open "DSN=mySystemDSN;" & _
>> >> "Uid=myUsername;" & _
>> >> "Pwd=myPassword"
>> >>
>> >> File DSN
>> >> ======
>> >> oConn.Open "FILEDSN=c:\somepath\mydb.dsn;" & _
>> >> "Uid=myUsername;" & _
>> >> "Pwd=myPassword"
>> >>
>> >> Note:
>> >> ====
>> >> The problem with DSN is that Users can (and will) modify or delete them by
>> >> mistake, then your program won't work so well. So it's better to use a
>> >> DSN-Less or OLE DB Provider connection string - with a Trusted Connection if
>> >> possible!
>> >>
>> >>
>> >>
>> >> About ODBC data sources
>> >> ================
>> >> http://msdn.microsoft.com/library/de...ataSources.asp
>> >>
>> >>
>> >> Login System (ASP.NET)
>> >> ================
>> >> http://www.codeproject.com/Purgatory/Login_System.asp
>> >>
>> >> For Anything & Everything, Please Let Me Know
>> >>
>> >> Bye
>> >> Venkat_KL
>>
>>
>>


Nov 19 '05 #13
in Version 1.1 you can use
using System.Data.Odbc;
I'm pretty sure that didn't exist in 1.0,
I don't know if it is still available in 2.0.
However as many have pointed out it is rather ineffcient.
I'm going to assume you probably have a reason that requires a dsn though.
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:OM**************@tk2msftngp13.phx.gbl...
You are trying to use ADO in ASP.NET.

For a zillion reasons that is not good.

re:
I could not believe that Microsoft does not allow
this kind of thing in ASP.Net for SQL connection.


Believe it.

Why would Microsoft include as an option something
which buries performance for web applications ?

Take a few minutes to see this ADO.NET presentation :
http://www.microsoft.com/seminar/sha...7/manifest.xml

Also, read the links on this page :
http://msdn.microsoft.com/library/de...withadonet.asp

Don't beat your head against the wall by trying to use ADO in ASP.NET.
You're only going to hurt yourself.


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:AE**********************************@microsof t.com...
Hi Juan,

I see your point, I am not just understanding if DSN definition is
possible
in APS.Net, where and how I will use it?

Here is a connection string I can use it ASP;
Set objADODBConn = CreateObject("ADODB.Connection")
strConn="DSN=" & MyODBC & ";UID=" & MyUsername & ";PWD=" & MyPassword &
";"
objADODBConn.Open(strConn)

I could not believe that Microsoft does not allow this kind of thing in
ASP.Net for SQL connection. DSN is still using native SQL Server driver
in
the system.
However thank you very much for your time.


"Juan T. Llibre" wrote:
re:
> once I create DSN how do I use it in the code?

I don't think you can use it, Jim.

There's no way for the DSN or FILEDSN parameters to be inserted
into a SQLConnection or a SQLCommand object, at least as far as I know.

That is why when you asked earlier :
>Will this "SqlCommand sqlCmd = new SqlCommand(sqlStr, myDSN);" work?

I replied : "No, it won't."

And, in the other thread you started on the same subject, I said :

>Other than a DSN is not an property of SqlConnection,
>and therefore you cannot use DSN with a SqlConnection

I just don't think that it can be done.
If you learn a way to do that, please post it and I will change my
opinion.


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"JIM.H." <JI**@discussions.microsoft.com> wrote in message
news:EB**********************************@microsof t.com...
> Hi Juan,
> Thanks for the reply. Ok. I understand it might be little bit slow
> through
> DSN, once I create DSN how do I use it in the code? Is there any way I
> can
> create SQLCommand through DSN.
> Thanks,
>
> "Juan T. Llibre" wrote:
>
>> re:
>> >Will this "SqlCommand sqlCmd = new SqlCommand(sqlStr, myDSN);" work?
>>
>> No, it won't. See my earlier reply.
>>
>>
>>
>> Juan T. Llibre, ASP.NET MVP
>> ASP.NET FAQ : http://asp.net.do/faq/
>> ASPNETFAQ.COM : http://www.aspnetfaq.com/
>> Foros de ASP.NET en Español : http://asp.net.do/foros/
>> ======================================
>> "JIM.H." <JI**@discussions.microsoft.com> wrote in message
>> news:28**********************************@microsof t.com...
>> > Hi Venkat_KL,
>> > Thank you very much for all this great help. Since I am using
>> > "this.sqlConnection1.ConnectionString" in many places such as
>> > "SqlCommand
>> > sqlCmd = new SqlCommand(sqlStr, connStr);" When I read my DSN from
>> > web.config
>> > with the example you gave, how should I use it instead of
>> > "this.sqlConnection1.ConnectionString" in my code? Will this
>> > "SqlCommand
>> > sqlCmd = new SqlCommand(sqlStr, myDSN);" work? I am new in asp.net
>> > and do not
>> > know all these details.
>> > Thanks,
>> >
>> >
>> >
>> >
>> > "Venkat_KL" wrote:
>> >
>> >> Hi Dear JIM.H,
>> >>
>> >> This is the sample where you give all your connection string
>> >> values inside
>> >> the asp.net file (ie. for example: in code behind)
>> >>
>> >> But in your case You have to give
>> >>
>> >> either
>> >>
>> >> "DSN=mySystemDSN;" & _
>> >> "Uid=myUsername;" & _
>> >> "Pwd=myPassword"
>> >>
>> >> or
>> >>
>> >> "FILEDSN=c:\somepath\mydb.dsn;" & _
>> >> "Uid=myUsername;" & _
>> >> "Pwd=myPassword"
>> >>
>> >> in you web.config in <appSettings></appSettings> section like
>> >> below
>> >>
>> >> <configuration>
>> >> <appSettings>
>> >> <add key="pubsDSN"
>> >> value="DSN=mySystemDSN;Uid=myUsername;Pwd=myPasswo rd"
>> >> />
>> >> </appSettings>
>> >> </configuration>
>> >>
>> >> OR
>> >>
>> >> <configuration>
>> >> <appSettings>
>> >> <add key="pubsFileDSN"
>> >> value="FILEDSN=c:\somepath\mydb.dsn;Uid=myUsername ;Pwd=myPassword"/>
>> >> </appSettings>
>> >> </configuration>
>> >>
>> >> and
>> >>
>> >> in your code behind to access the web.config file DSN/FileDSN
>> >>
>> >> Dim dsn As String = ConfigurationSettings.AppSettings("pubsDSN")
>> >> or
>> >> Dim dsn As String =
>> >> ConfigurationSettings.AppSettings("pubsFileDSN")
>> >>
>> >>
>> >> ODBC DSN
>> >> =======
>> >> Using an ODBC DSN (Data Source Name) is a two step process.
>> >>
>> >> 1) You must first create the DSN via the "ODBC Data Source
>> >> Administrator"
>> >> program found in your computer's Control Panel (or Administrative
>> >> Tools menu
>> >> in Windows 2000). Make sure to create a SYSTEM DSN (not a USER
>> >> DSN) when
>> >> using ASP(I think same thing holds good for ASP.NET).
>> >>
>> >> 2) Then use the following connection string - with your own DSN
>> >> name of course.
>> >>
>> >> DSN
>> >> ====
>> >> oConn.Open "DSN=mySystemDSN;" & _
>> >> "Uid=myUsername;" & _
>> >> "Pwd=myPassword"
>> >>
>> >> File DSN
>> >> ======
>> >> oConn.Open "FILEDSN=c:\somepath\mydb.dsn;" & _
>> >> "Uid=myUsername;" & _
>> >> "Pwd=myPassword"
>> >>
>> >> Note:
>> >> ====
>> >> The problem with DSN is that Users can (and will) modify or delete
>> >> them by
>> >> mistake, then your program won't work so well. So it's better to
>> >> use a
>> >> DSN-Less or OLE DB Provider connection string - with a Trusted
>> >> Connection if
>> >> possible!
>> >>
>> >>
>> >>
>> >> About ODBC data sources
>> >> ================
>> >> http://msdn.microsoft.com/library/de...ataSources.asp
>> >>
>> >>
>> >> Login System (ASP.NET)
>> >> ================
>> >> http://www.codeproject.com/Purgatory/Login_System.asp
>> >>
>> >> For Anything & Everything, Please Let Me Know
>> >>
>> >> Bye
>> >> Venkat_KL
>>
>>
>>


Nov 19 '05 #14

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Enos Meroka | last post: by
3 posts views Thread by Mike L | last post: by
3 posts views Thread by xzzy | last post: by
14 posts views Thread by pmud | last post: by
8 posts views Thread by acb | last post: by
reply views Thread by Metal2You | last post: by
reply views Thread by Eugene Anthony | last post: by
6 posts views Thread by =?Utf-8?B?U2hhd24gU2VzbmE=?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.