By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,813 Members | 1,252 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,813 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
7 Replies


P: n/a
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.OleDb namespace, and if you really have to use ODBC, you can
use the system.Data.Odbc .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******@promastar.com> wrote in message
news:uK**************@tk2msftngp13.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

P: n/a
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

P: n/a
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**************@TK2MSFTNGP10.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.OleDb namespace, and if you really have to use ODBC, you can use the system.Data.Odbc .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******@promastar.com> wrote in message
news:uK**************@tk2msftngp13.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

P: n/a
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.Odbc namespace.

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

"Reza" <uw******@hotmail.com> wrote in message
news:D5**********************************@microsof t.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

P: n/a
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.Page
Protected DC As New Data.Odbc.OdbcConnection
Protected DA As New Data.Odbc.OdbcDataAdapter
Protected WithEvents DG As System.Web.UI.WebControls.DataGrid
Protected DS As New Data.DataSet
Protected DataGrid_Sort As String

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
DataGrid_Sort = "ID"
Bind_Grid(DataGrid_Sort)
Else
Bind_Grid(DataGrid_Sort)
End If
End Sub

Private Sub Bind_Grid(ByVal sorting As String)
If DC.State = ConnectionState.Open Then DC.Close()
DS.Clear()
DC.ConnectionString = "MaxBufferSize=2048;FIL=MS
Access;DSN=MyDSN;PageTimeout=5"
DC.Open()
DA.SelectCommand = New Data.Odbc.OdbcCommand("select * from [main]",
DC)
DA.Fill(DS)
Dim DV As New Data.DataView(DS.Tables(0))
DV.Sort = sorting
DG.DataSource = DV
DG.Visible = True
DG.AllowSorting = True
DG.DataBind()

End Sub

"HB" <hb******@promastar.com> wrote in message
news:uK**************@tk2msftngp13.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

P: n/a
Pretty sure you're going to need the 1.1 framework
in order to use System.Data.Odbc.

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

"HB" <hb******@promastar.com> wrote in message news:<uK**************@tk2msftngp13.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

P: n/a
> Pretty sure you're going to need the 1.1 framework
in order to use System.Data.Odbc.
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.google.c om... Pretty sure you're going to need the 1.1 framework
in order to use System.Data.Odbc.

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

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

news:<uK**************@tk2msftngp13.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 discussion thread is closed

Replies have been disabled for this discussion.