We help IT Professionals succeed at work.
Get Started

Do you know how to correct my C# .Net code to make a Sybase ODBC connection from a windows form?

Last Modified: 2013-11-07
I am developing a C# .Net Windows application using Visual Studio 2005.
I need to call Sybase Stored Procedures from the application.
I use a Sybase ODBC connection as follows:

User Data Sources
Name  NYP              Driver   DataDirect 4.0 Sybase WIre Protocol

I have created the following code so far:

private void stored_procedure1()
            OdbcConnection _cn = new OdbcConnection("Data Source=NYP;Database=ap;User ID=PW;Password=XX;");                                
            System.Data.SqlClient.SqlCommand comm2 = _cn.CreateCommand();
            comm.CommandType = System.Data.CommandType.StoredProcedure;
            comm.CommandText = string.Format("sp3D_GetListOfDocuments");
            System.Data.DataSet dataSet = new System.Data.DataSet();
            System.Data.SqlClient.SqlDataAdapter sqlDataAdapter = new System.Data.SqlClient.SqlDataAdapter(comm2);
I get the following error:

Cannot implicitly convert type 'System.Data.Odbc.OdbcCommand' to 'System.Data.SqlClient.SqlCommand'      

The error is on the following line:
 System.Data.SqlClient.SqlCommand comm2 = _cn.CreateCommand();

Do you know how I can fix this error and do you see any other problems with this code ?
Watch Question
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE