473,651 Members | 2,466 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to use ODBC with a DB connection in ASP.NET

HB
Guys,

How to use ODBC with a DB connection in ASP.NET?
each time I try to add the ODBC name in the connection an error telling that
it is not compatible (or so) to use ODBC.

I have .NET 2002 with ver. 1 framework.

Thanks

HB
Nov 18 '05 #1
7 1599
Okay, first of all, can you tell me why you want to use ODBC? Are you using
a database product that doesn't have an OLE DB driver? Otherwise, you should
know that ODBC is a nearly-obsolete wrapper for OLE DB, and yields much
poorer performance. If you're using SQL Server or Oracle, there are .Net
managed classes to work with them. Otherwise, if you use OLE DB, you can use
the System.Data.Ole Db namespace, and if you really have to use ODBC, you can
use the system.Data.Odb c .Net managed classes.

Next time, the actual error message would be very helpful. :)

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"HB" <hb******@proma star.com> wrote in message
news:uK******** ******@tk2msftn gp13.phx.gbl...
Guys,

How to use ODBC with a DB connection in ASP.NET?
each time I try to add the ODBC name in the connection an error telling that it is not compatible (or so) to use ODBC.

I have .NET 2002 with ver. 1 framework.

Thanks

HB

Nov 18 '05 #2
Since I have the same problem, would add a little bit here
I agree with Kevin to use OleDb for oracle but, in case of databases very old such as db2 or so, what would be the best approach

Thanks
Reza
Nov 18 '05 #3
HB
Thanks for your help

Error MSG is "The connection you have created does not work with the current
adapter"

How to let the DataGrid to use a connection that is pointed to an ODBC?

Reason of my strange inquiry that the customer I am developing a web app is
not sure if he will use SQL or Oracle
so by using the ODBC I do not have to do any modification due to DB select.
I will appreciate any suggestions.

Thanks

HB

"Kevin Spencer" <ke***@takempis .com> wrote in message
news:OX******** ******@TK2MSFTN GP10.phx.gbl...
Okay, first of all, can you tell me why you want to use ODBC? Are you using a database product that doesn't have an OLE DB driver? Otherwise, you should know that ODBC is a nearly-obsolete wrapper for OLE DB, and yields much
poorer performance. If you're using SQL Server or Oracle, there are .Net
managed classes to work with them. Otherwise, if you use OLE DB, you can use the System.Data.Ole Db namespace, and if you really have to use ODBC, you can use the system.Data.Odb c .Net managed classes.

Next time, the actual error message would be very helpful. :)

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"HB" <hb******@proma star.com> wrote in message
news:uK******** ******@tk2msftn gp13.phx.gbl...
Guys,

How to use ODBC with a DB connection in ASP.NET?
each time I try to add the ODBC name in the connection an error telling

that
it is not compatible (or so) to use ODBC.

I have .NET 2002 with ver. 1 framework.

Thanks

HB


Nov 18 '05 #4
As I mentioned in my message, some databases don't come with OLE DB drivers.
If the database doesn't have an OLE DB driver, but does have an ODBC driver,
by all means use ODBC, and use the System.Data.Odb c namespace.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Reza" <uw******@hotma il.com> wrote in message
news:D5******** *************** ***********@mic rosoft.com...
Since I have the same problem, would add a little bit here.
I agree with Kevin to use OleDb for oracle but, in case of databases very old such as db2 or so, what would be the best approach?
Thanks,
Reza

Nov 18 '05 #5
Create an aspx page with a DataGrid named DG. Then the following code will
populate it from an Access database with DSN named MyDSN. The datagrid is
also sortable.

Public Class ODBCTest
Inherits System.Web.UI.P age
Protected DC As New Data.Odbc.OdbcC onnection
Protected DA As New Data.Odbc.OdbcD ataAdapter
Protected WithEvents DG As System.Web.UI.W ebControls.Data Grid
Protected DS As New Data.DataSet
Protected DataGrid_Sort As String

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
If Not IsPostBack Then
DataGrid_Sort = "ID"
Bind_Grid(DataG rid_Sort)
Else
Bind_Grid(DataG rid_Sort)
End If
End Sub

Private Sub Bind_Grid(ByVal sorting As String)
If DC.State = ConnectionState .Open Then DC.Close()
DS.Clear()
DC.ConnectionSt ring = "MaxBufferSize= 2048;FIL=MS
Access;DSN=MyDS N;PageTimeout=5 "
DC.Open()
DA.SelectComman d = New Data.Odbc.OdbcC ommand("select * from [main]",
DC)
DA.Fill(DS)
Dim DV As New Data.DataView(D S.Tables(0))
DV.Sort = sorting
DG.DataSource = DV
DG.Visible = True
DG.AllowSorting = True
DG.DataBind()

End Sub

"HB" <hb******@proma star.com> wrote in message
news:uK******** ******@tk2msftn gp13.phx.gbl...
Guys,

How to use ODBC with a DB connection in ASP.NET?
each time I try to add the ODBC name in the connection an error telling that it is not compatible (or so) to use ODBC.

I have .NET 2002 with ver. 1 framework.

Thanks

HB

Nov 18 '05 #6
Pretty sure you're going to need the 1.1 framework
in order to use System.Data.Odb c.

Then you'll have access to stuff like OdbcConnection and OdbcDataAdapter .

"HB" <hb******@proma star.com> wrote in message news:<uK******* *******@tk2msft ngp13.phx.gbl>. ..
Guys,

How to use ODBC with a DB connection in ASP.NET?
each time I try to add the ODBC name in the connection an error telling that
it is not compatible (or so) to use ODBC.

I have .NET 2002 with ver. 1 framework.

Thanks

HB

Nov 18 '05 #7
> Pretty sure you're going to need the 1.1 framework
in order to use System.Data.Odb c.
That is correct. I just checked.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"jim corey" <jh*****@yahoo. com> wrote in message
news:1c******** *************** ***@posting.goo gle.com... Pretty sure you're going to need the 1.1 framework
in order to use System.Data.Odb c.

Then you'll have access to stuff like OdbcConnection and OdbcDataAdapter .

"HB" <hb******@proma star.com> wrote in message

news:<uK******* *******@tk2msft ngp13.phx.gbl>. ..
Guys,

How to use ODBC with a DB connection in ASP.NET?
each time I try to add the ODBC name in the connection an error telling that it is not compatible (or so) to use ODBC.

I have .NET 2002 with ver. 1 framework.

Thanks

HB

Nov 18 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
5203
by: Sean Anderson | last post by:
ODBC under System DSN Setup Access Driver give it the DSN (Data Source Name) MSA Click on Select and point to the myfile.mdb (your database file)
5
102527
by: SerGioGio | last post by:
Hello, I am going nuts. I am trying to connect to my local ORACLE instance using ODBC. It used to work few weeks ago, but it fails now. Connection with: - SQL*plus: connection works! - DataDirect 5.0 Oracle Wire protocol (3rd party ODBC driver): connection works when I hit the driver's "test connection"
11
17548
by: DJJ | last post by:
I am using the MySQL ODBC 3.51 driver to link three relatively small MySQL tables to a Microsoft Access 2003 database. I am finding that the data from the MySQL tables takes a hell of a long time to load making any kind linkage with my Access data virtually useless. I have the MySQL driver setup in as a USER DSN. The MySQL data is sitting out on a server and the Access database is running locally. The network connection is very...
14
9024
by: jj | last post by:
Is it possible to call a remote php script from within Access? I'm thinking something like: DoCMD... http://www.domain.com/scripts/dataquery.php DoCmd.OpenQuery "update_data", acNormal, acEdit ..... So the PHP script does something on the server database, then when a linked table is viewed within access, the data changes have been made?
5
40400
by: Alec | last post by:
Hi All, I am currently trying to link in Access 97 to a table in a MSSQL 7 server. Initially the link is fine, however, when I close the access database and re-open it from the same network lacation on a different machine, it tells me that the ODBC connection to 'SQL Server Name' failed. How can I create the linked table permenant no matter what machine the networked database is opened on?
1
3793
by: Paul | last post by:
Hello, I am converting an Access database on our network to a sql 2000 backend and keeping access as the front end. The access database has evolved and been a solution to collect data but now we want to move the tables over to sql 2000. We have successfully done that but are now having difficulties with an ODBC connection. Initiall linking the tables is not an issue and I am able to connect with no problem. However after closing down...
4
3566
by: Dave | last post by:
Hey guys, I have an ODBC problem that has me stumped. I wrote a VBA script to run in Microsoft Excel that pulls data out of an application using that application's ODBC driver and puts it into Excel. I am trying to translate the same program over to Microsoft Access and I ran into a problem. Access locks up if the data I am querying for is not present in the database. To retrieve data from the database of the application, my Excel...
9
17020
by: mcbill20 | last post by:
Hello all. I just installed Oracle 10g developer tools on a machine running XP Pro and Office XP. Before this I had just the Oracle 9 client installed. I the previous configuration, I was able to access any of the Oracle tables on another machine but now I am having problems. Unfortunately, I don't remember the correct syntax for the ODBC connect string and I am hoping that is my whole problem. I am trying to connect to an Oracle 9...
8
9628
by: Greg Strong | last post by:
Hello All, The short questions are 1 Do you know how to make DSN connection close in Access to Oracle 10g Express Edition? &/or 2 Do you know how to make a DSN-less pass-through query work from
2
9380
by: 111mike | last post by:
Hello, Here's my problem. I cannot connect to mysql database using odbc string connections or dns. I keep getting a "cannot connect to mysql server localhost." I'm running windows XP Pro and have installed IIS as my server. I have installed Mysql 5.0 and mysql ODBC driver 3.51.12 in their default locations. Database is up and running okay, as I've been able to create databases and tables and access them via the command prompt and...
0
8349
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8795
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8695
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
6157
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5609
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4143
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2696
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1906
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1585
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.