[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Denis L. Menezes

8/30/2002 6:41:00 AM

Hello friends.

I am a newcomer to asp.net. I have an access database on my web server(at an
isp) and I have configured the DSN as "northwind" and the path is
wwwroot/data/northwind.mdb.

Now I wish to access the data using asp.net. I have found many books which
give the code for sql and oldb connecvtion. But I cannot find any code on
how I can connect to this database dsn.

Can someone guide me to some code?

Thanks
Denis




4 Answers

(Elan Zhou(MS))

9/3/2002 7:00:00 AM

0

Hi,

You can use the ODBC.NET Managed Provider.
1. You can download and install ODBC.NET Managed Provider from the
following location:

http://msdn.microsoft.com/downloads/default.asp?url=/downloads/sam...
l=/msdn-files/027/001/668/msdncompositedoc.xml

2. In your.NET project, add the reference to Microsoft.Data.Odbc.dll.
3. Here is a small code snippet for your reference:
Imports System.Data
Imports Microsoft.Data.Odbc
. . .
. . .
Dim sConnectionString As String
sConnectionString = "dsn=northwind"
Dim objConn As New OdbcConnection(sConnectionString)
Dim da As New OdbcDataAdapter("Select * From Customers", objConn)
Dim ds As New DataSet()
da.Fill(ds, "Customers")
DataGrid1.DataSource = ds
DataGrid1.DataBind()

Regards,
Elan Zhou
This posting is provided "AS IS" with no warranties, and confers no rights.
Got .Net? http://www.got...

=?iso-8859-1?Q?Jos=E9_Carlos?=

9/3/2002 10:19:00 AM

0

When I try a very similar example I get this message:


C:\WINDOWS\system32> "c:\windows\microsoft.net\framework\v1
.0.3705\vbc.exe" [...]

Microsoft (R) Visual Basic .NET Compiler version 7.00.9466
for Microsoft (R) .NET Framework version 1.00.3705.288
Copyright (C) Microsoft Corporation 1987-2001. All rights=20
reserved.

C:\WINDOWS\Microsoft.NET\Framework\v1.0.3705\Temporary=20
ASP.NET Files\root\08853a15\3ed8a8fe\n3f5i6ed.0.vb(14) :=20
error BC30466: Namespace or type 'Odbc' for the=20
Imports 'Microsoft.Data.Odbc' cannot be found.

Imports Microsoft.Data.Odbc
~~~~~~~~~~~~~~~~~~~
D:\wwwroot\14_6.aspx(13) : error BC30002:=20
Type 'OdbcConnection' is not defined.


Do you know how to fix it?

Thank you,
Jos=E9 Carlos



>-----Original Message-----
>Hi,
>
>You can use the ODBC.NET Managed Provider.=20
>1. You can download and install ODBC.NET Managed Provider=20
from the=20
>following location:=20
> =20
>http://msdn.microsoft.com/downloads/de...
url=3D/downloads/sample.asp?ur
>l=3D/msdn-files/027/001/668/msdncompositedoc.xml=20
>
>2. In your.NET project, add the reference to=20
Microsoft.Data.Odbc.dll.=20
>3. Here is a small code snippet for your reference:=20
> Imports System.Data
> Imports Microsoft.Data.Odbc
> . . . =20
> . . .
> Dim sConnectionString As String
> sConnectionString =3D "dsn=3Dnorthwind"
> Dim objConn As New OdbcConnection
(sConnectionString)
> Dim da As New OdbcDataAdapter("Select * From=20
Customers", objConn)
> Dim ds As New DataSet()
> da.Fill(ds, "Customers")
> DataGrid1.DataSource =3D ds
> DataGrid1.DataBind()
>
>Regards,
>Elan Zhou
>This posting is provided "AS IS" with no warranties, and=20
confers no rights.=20
>Got .Net? http://www.got...
>
>.
>

(Elan Zhou(MS))

9/10/2002 6:31:00 AM

0

Hi,

Please check if the following article applies to your situation:
PRB: Error Messages When You Use ODBC .NET Data Provider in WebForm
Applications
http://support.microsoft.com/default.aspx?scid=KB;EN-US;q3...

Regards,
Elan Zhou
This posting is provided "AS IS" with no warranties, and confers no rights.
Got .Net? http://www.got...

Matt

9/10/2002 11:19:00 PM

0

I tried to establish a connection similar to this but I
got an unhandled exception on the da.Fill
(ds, "Customers") snippet. Any ideas what could be
causing this?

>-----Original Message-----
>Hi,
>
>You can use the ODBC.NET Managed Provider.
>1. You can download and install ODBC.NET Managed
Provider from the
>following location:
>
>http://msdn.microsoft.com/downloads/de...
url=/downloads/sample.asp?ur
>l=/msdn-files/027/001/668/msdncompositedoc.xml
>
>2. In your.NET project, add the reference to
Microsoft.Data.Odbc.dll.
>3. Here is a small code snippet for your reference:
> Imports System.Data
> Imports Microsoft.Data.Odbc
> . . .
> . . .
> Dim sConnectionString As String
> sConnectionString = "dsn=northwind"
> Dim objConn As New OdbcConnection
(sConnectionString)
> Dim da As New OdbcDataAdapter("Select * From
Customers", objConn)
> Dim ds As New DataSet()
> da.Fill(ds, "Customers")
> DataGrid1.DataSource = ds
> DataGrid1.DataBind()
>
>Regards,
>Elan Zhou
>This posting is provided "AS IS" with no warranties, and
confers no rights.
>Got .Net? http://www.got...
>
>.
>