473,236 Members | 1,751 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,236 software developers and data experts.

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 3531
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Enos Meroka | last post by:
Hallo, I am a student doing my project in the university.. I have been trying to compile the program using HP -UX aCC compiler, however I keep on getting the following errors. ...
3
by: Mike L | last post by:
Should the command call "using" be before or after my namespace? **AFTER** namespace DataGridBrowser { using System; using System.Drawing; using System.Drawing.Drawing2D; using...
3
by: xzzy | last post by:
I was wondering why we have to have using System.Data using System.Configuration using etc.... why are they not all lumped into one 'using'? In other words, is there a best way to use...
14
by: pmud | last post by:
Hi, I need to use an Excel Sheet in ASP.NET application so that the users can enter (copy, paste ) large number of rows in this Excel Sheet. Also, Whatever the USER ENETRS needs to go to the...
8
by: acb | last post by:
Hi, I wrote a DLL Component (using Visual Studio 2005) and managed to include it into a C# Console application. I am now trying to include this component into a Web project. I copy the DLL...
0
by: Metal2You | last post by:
I'm working on an ASP.NET 2.0 application in Visual Studio 2005 that accesses a Sybase database back end. We're using Sybase SQL Anywhere 9.0.2.3228. I have installed and registered the Sybase...
10
by: mg | last post by:
I'm migrating from VB6 and have a question about using 'Using' and the best way to use it. Here is a example of a small bit of code: dbConx("open") Using CN Dim CMD As New OleDbCommand(sSQL,...
0
by: Eugene Anthony | last post by:
The problem with my coding is that despite removing the records stored in the array list, the rptPages repeater control is still visible. The rptPages repeater control displayes the navigation...
3
by: JDeats | last post by:
I have some .NET 1.1 code that utilizes this technique for encrypting and decrypting a file. http://support.microsoft.com/kb/307010 In .NET 2.0 this approach is not fully supported (a .NET 2.0...
6
by: =?Utf-8?B?U2hhd24gU2VzbmE=?= | last post by:
Greetings! I was researching AJAX to provide a solution to displaying status messages while a long process executed. I found several examples online and was able to use their code to get a quick...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.