Hello everyone, I am new to this forum. I am having problems connecting to Sybase Adaptive Server Enterprise 12 and was hoping someone could help. The server is set up as follows: Sybase Adaptive Server Enterprise Client .net Framework IIS 6 ODBC .net I have
tried to connect a couple of different ways. First is using the following code: ------------------------------------------------------------------------------------------------------ <script runat="server"> Sub Page_Load(Source as object, e as EventArgs) If
Not IsPostBack Then Dim sConnString As String = "Driver={Sybase ASE ODBC Driver};srvr=myServer;DB=myDatabase;UID=myUserID;PWD=myPassword;" Dim conn As ODBCConnection conn = New ODBCConnection(sConnString) conn.Open() ------------------------------------------------------------------------------------------------------
With that code I get the following error: Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30560: 'ODBCConnection' is ambiguous in the namespace 'Microsoft.Data.Odbc'. ----------------------------------------------------------------------------------------------------- I have also tried the following code: -----------------------------------------------------------------------------------------------------
<script runat="server"> Sub Page_Load(Source as object, e as EventArgs) If Not IsPostBack Then Dim sConnString As String = "Driver={Sybase ASE ODBC Driver};srvr=myServer;DB=myDatabase;UID=myUserID;PWD=myPassword;" Dim conn As ODBCConnection conn = New ODBCConnection(sConnString)
conn.Open() ----------------------------------------------------------------------------------------------------- With that code I get the following error: ERROR [IM002] [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.Odbc.OdbcException: ERROR [IM002]
[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified ----------------------------------------------------------------------------------------------------- Both pieces of code work on a stand alone computer that I had
used for development, but once I moved the code to the production server I started having problems. Both the server and desktop were setup the same way. Has anyone encounter and been able to fix either of those errors? I have spent the last week trying to
figure out how to fix the problem. Thanks for reading this.
If you are not using SQL Server you can probably drop the line. Do you have the Sybase ODBC driver installed and configured on the production machine? Use the Windows ODBC Manager to test connecting to Sybase to make sure. Also, when putting code on the site
you can use the < code > this is code < /code > (without spaces) to meet standards on the site. :) For example:
<script runat="server">
Sub Page_Load(Source as object, e as EventArgs)
If Not IsPostBack Then
Dim sConnString As String = "Driver={Sybase ASE ODBC Driver};srvr=myServer;DB=myDatabase;UID=myUserID;PWD=myPassword;"
Dim conn As ODBCConnection
conn = New ODBCConnection(sConnString)
conn.Open()
HTH
Keith Barrows
Ad Astra Per Aspera - "To the stars thru difficulties"
Sorry for not putting tags around the code. I will do that going forward. I am using SQL Server on the page too. Ultimately I would like to grab data from Sybase and combined it with data that an end user would type into a form and store it all in SQL Server.
If I comment out the Sybase connection, the page works and I am able to connect to SQL Server. So the only problem right now is the Sybase portion. I do have Sybase ODBC drivers installed. It comes as part of the Sybase ASE Client install. I set up the System
DSN and tested the connection. The connection works, but once I try the web page, it comes up with the above errors. I have also tried referencing the DSN in my code and that too returns an error.
Try this url for the correct way to use Microsoft ODBC. I would also look at the book at my local book store. BTW the namespace is Microsoft.Data.Odbc Hope this helps.
I am getting the same error too. My odbc connection works fine for the sybase if tested from control panel>odbc manager but gives the above error when executed from code, for this connection string.
conn = new OdbcConnection("Data Source=pundev;Database=xyz;na=7000;User ID=sa;Password=12345");
Fio316
Member
10 Points
2 Posts
Connecting to Sybase using ODBC
Feb 04, 2005 09:21 PM|LINK
StarPilot
Participant
1240 Points
248 Posts
ASPInsiders
Re: Connecting to Sybase using ODBC
Feb 04, 2005 09:31 PM|LINK
<script runat="server"> Sub Page_Load(Source as object, e as EventArgs) If Not IsPostBack Then Dim sConnString As String = "Driver={Sybase ASE ODBC Driver};srvr=myServer;DB=myDatabase;UID=myUserID;PWD=myPassword;" Dim conn As ODBCConnection conn = New ODBCConnection(sConnString) conn.Open()HTHAd Astra Per Aspera - "To the stars thru difficulties"
Fio316
Member
10 Points
2 Posts
Re: Connecting to Sybase using ODBC
Feb 05, 2005 05:20 PM|LINK
Shuliliea
Member
5 Points
1 Post
Re: Connecting to Sybase using ODBC
Apr 29, 2005 03:29 PM|LINK
Caddre
All-Star
26581 Points
5308 Posts
Re: Connecting to Sybase using ODBC
Apr 29, 2005 04:49 PM|LINK
Try this url for the correct way to use Microsoft ODBC. I would also look at the book at my local book store. BTW the namespace is Microsoft.Data.Odbc Hope this helps.
http://www.c-sharpcorner.com/Code/2002/Sept/ODBCDataProvider1.asp
Gift Peddie
Vinitksingh
Member
6 Points
3 Posts
Re: Connecting to Sybase using ODBC
Jan 10, 2010 04:07 AM|LINK
Friends,
I am getting the same error too. My odbc connection works fine for the sybase if tested from control panel>odbc manager but gives the above error when executed from code, for this connection string.
conn = new OdbcConnection("Data Source=pundev;Database=xyz;na=7000;User ID=sa;Password=12345");
Can you suggest any solution?
Regards.
sybase connection
Vinitksingh
Member
6 Points
3 Posts
Re: Connecting to Sybase using ODBC
Jan 10, 2010 04:09 AM|LINK
Caddre,
Sorry the link you provided is broken, can you repost the corrected one.
Thanks.
Vinitksingh
Member
6 Points
3 Posts
Re: Connecting to Sybase using ODBC
Jan 10, 2010 05:18 AM|LINK
I figured it out, user name and pass were missing. Silly mistake, isn't it ;)
This is the corrected one, for your reference
conn = new OdbcConnection("Dsn=pbdev;Uid=sa;Pwd=dev125");