|
 |
asptoday_discuss thread: DSN's and .net
Message #1 by "Max Campsell" <pamax@i...> on Mon, 7 Jan 2002 20:03:25
|
|
Can anybody show me an example of connecting to SQL Server, using either
c# or VB.net.
For example the code below is fine.
private DataSet CreateDataSet()
{
string source = "data source=OURSERVER;initial
catalog=Images;integrated security=SSPI;persist security
info=True;workstation id=MYSVR;packet size=4096";
string logdata;
logdata = "SELECT Top 200 Message, DateLogged, ErrorLevel, UnitID
FROM MessageLog ORDER BY DateLogged DESC";
SqlConnection cn = new SqlConnection(source);
SqlDataAdapter da = new SqlDataAdapter(logdata,cn);
DataSet ds = new DataSet();
da.Fill(ds, "LogData");
return ds;
}
I would like to use a DSN instead of the connect string, has anybody got
an idea how to connect to SQL Server using a DSN and either OleDbConnection
() object or SqlConnection() object.
Thanks Max Campsell
Message #2 by "Douglas Rohm" <dlr@m...> on Mon, 7 Jan 2002 16:43:09 -0500
|
|
The .NET team took out the ability to use DSN's through the OleDb data
provider. I think the reason why was because of the added layer that it
would add (OLE DB -> ODBC -> Data Source). If you want to connect to a
data source using DSN's you need to use the .NET Odbc data provider. It
isn't included in the .NET SDK download, you have to download it
seperately. The URL is:
http://www.microsoft.com/downloads/release.asp?ReleaseID=31125&area=sear
ch&ordinal=1
At the moment, you can use this .NET Odbc data provider to connect to
SQL Server, Oracle, and Jet.
Hope this helps.
Doug
-----Original Message-----
From: Max Campsell [mailto:pamax@i...]
Sent: Monday, January 07, 2002 8:03 PM
To: ASPToday Discuss
Subject: [asptoday_discuss] DSN's and .net
Can anybody show me an example of connecting to SQL Server, using either
c# or VB.net.
For example the code below is fine.
private DataSet CreateDataSet()
{
string source = "data source=OURSERVER;initial
catalog=Images;integrated security=SSPI;persist security
info=True;workstation id=MYSVR;packet size=4096";
string logdata;
logdata = "SELECT Top 200 Message, DateLogged, ErrorLevel,
UnitID
FROM MessageLog ORDER BY DateLogged DESC";
SqlConnection cn = new SqlConnection(source);
SqlDataAdapter da = new SqlDataAdapter(logdata,cn);
DataSet ds = new DataSet();
da.Fill(ds, "LogData");
return ds;
}
I would like to use a DSN instead of the connect string, has anybody got
an idea how to connect to SQL Server using a DSN and either
OleDbConnection
() object or SqlConnection() object.
Thanks Max Campsell
Message #3 by "Patrick" <patrick00@n...> on Mon, 7 Jan 2002 20:47:14 -0000
|
|
Try This
set connection = server.createobject("adodb.connection") connection.open
"DSN=dsnName"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "SELECT * FROM messages WHERE id =001"
Regards
Patrick
----- Original Message -----
From: "Max Campsell" <pamax@i...>
To: "ASPToday Discuss" <asptoday_discuss@p...>
Sent: Monday, January 07, 2002 8:03 PM
Subject: [asptoday_discuss] DSN's and .net
> Can anybody show me an example of connecting to SQL Server, using either
> c# or VB.net.
> For example the code below is fine.
>
> private DataSet CreateDataSet()
> {
> string source = "data source=OURSERVER;initial
> catalog=Images;integrated security=SSPI;persist security
> info=True;workstation id=MYSVR;packet size=4096";
> string logdata;
> logdata = "SELECT Top 200 Message, DateLogged, ErrorLevel, UnitID
> FROM MessageLog ORDER BY DateLogged DESC";
> SqlConnection cn = new SqlConnection(source);
> SqlDataAdapter da = new SqlDataAdapter(logdata,cn);
> DataSet ds = new DataSet();
> da.Fill(ds, "LogData");
> return ds;
> }
>
> I would like to use a DSN instead of the connect string, has anybody got
> an idea how to connect to SQL Server using a DSN and either
OleDbConnection
> () object or SqlConnection() object.
>
> Thanks Max Campsell
>
|
|
 |