Multimobile Development: Building Applications for any Smartphone
DSN Connection using MS Access
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.odbcnet.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.

Gayathri
Hi,

I am trying to do a DSN connection using MS Access. I downloaded the
ODBC .NET Provider and installed MDAC 2.7 RTM Refresh. I created a
project(using VS.NET) and added reference to Microsoft.Data.ODBC.dll.
I have imported these two namespaces also:

Imports System.Data
Imports Microsoft.Data.ODBC

When ever I run the application it is giving the following error:
ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not
found and no default driver specified

Could any one help me with this?

My page_load event looks like this:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then

Dim ds As New DataSet()
Dim cnnorthwind As OdbcConnection

Dim daproducts As OdbcDataAdapter
Dim dvproducts As New System.Data.DataView()

cnnorthwind = New
OdbcConnection("Provider=Microsoft.Jet.OLEDB.4.0;dsn=dsncnwind")
daproducts = New OdbcDataAdapter("SELECT * FROM products",
cnnorthwind)
daproducts.Fill(ds, "products")
dvproducts = ds.Tables("products").DefaultView
dvproducts.RowFilter = "CategoryID=4"
dvproducts.Sort = "ProductName"

Dim i As Integer
i = dvproducts.Find("Flotemysost")
If i <> -1 Then
Response.Write("Product ID = ")
Response.Write(dvproducts(i).Row("ProductID"))
Else
Response.Write("The value you are searching is not
found")

End If
DataGrid1.DataSource = dvproducts
DataGrid1.DataBind()

End If
Reply to this message...
Vote that this is a GOOD answer...
 
Really good experience at the Apple Store
MonoDroid – looking *awesome*
 
    
Hussein Abuthuraya[MSFT] (VIP)
Your connectionstring is incorrect. When you create a DSN you are using an ODBC Driver so in your connection string you cant specify the Jet OLEDB provider and an
ODBC driver.

Also for Web pages, the DSN has to be a System DSN and not a User DSN.

A correct connectionstring to be used with ODBC .NET is "DSN=dsncnwind". Another important thing when using ODBC with Web Pages is setting the correct permissions on
the System DSN in the registry for that entry. The Internet Guest Account (IUSR and/or IWAM account) has to be added to the registry key for the DSN otherwise you are
going to get "Access denied" and it will not load the system DSN and through the error " Data source name not found and no default driver specified"

I hope this helps!

Thanks,
Hussein Abuthuraya
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.

Reply to this message...
Vote that this is a GOOD answer...
 
 
    
Gayathri Thirumalai
Thanks a lot for your help. It worked. I wasn't using a system DSN
connection.

Gayathri

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Reply to this message...
Vote that this is a GOOD answer...
 
 
 
System.Data.DataSet
System.Data.DataView
System.Data.Odbc.OdbcConnection
System.Data.Odbc.OdbcDataAdapter
System.EventArgs
System.Object




Multimobile Development: Building Applications for any Smartphone
Ad
BootFX
Reliable and powerful .NET application framework.
iOS, Android and Windows Phone Development Training and Consultancy
Hosted by RackSRV Communications
 
Multimobile Development: Building Applications for any Smartphone
Copyright © AMX Software Ltd 2008-2010. Portions copyright © Matthew Baxter-Reynolds 2001-2010. All rights reserved.
Contact Us - Terms of Use - Privacy Policy - 4.0.30129.1734