help with sybase connection (Connecting using Sybase.Data.Aseclient) RRS feed

  • Question


    Hi All,
    I am trying to write a small application that will connect to a sybase database and will run a querie.
    This queirie should be outputted to a lable text later on.
    The sybase database is installed on a unix server.
    usually we connect to it using telnet to the unix and then running the isql command.
    I want this application in order to save all of this telnet sessions.
    this is what i have so far.

    I am using the Sybase.Data.Aseclient.dll referance.
    but i still have problems connecting to the server.
    Hope you guys can help me out.
    i got this code from another forum regarding the connection but i get errors.

       AseConnection oAseConn = new AseConnection();
       oAseConn.ConnectionString = "Data Source=;" +
                                "Initial Catalog=;" +
                                "User ID=database;" +

    i get the following error
    connetion to sybase server has been lost. all active transactions have been rolled back.

    See the end of this message for details on invoking
    just-in-time (JIT) debugging instead of this dialog box.

    ************** Exception Text **************
    Sybase.Data.AseClient.AseException: Connection to Sybase server has been lost. All active transactions have been rolled back
       at Sybase.Data.AseClient.AseConnectionPool.GetConnection(AseConnection conn)
       at Sybase.Data.AseClient.AseConnection.Open()
       at WindowsApplication3.Form1.button1_Click(Object sender, EventArgs e) in c:\documents and settings\administrator\my documents\visual studio projects\windowsapplication3\form1.cs:line 96
       at System.Windows.Forms.Control.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnClick(EventArgs e)
       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ButtonBase.WndProc(Message& m)
       at System.Windows.Forms.Button.WndProc(Message& m)
       at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

    ************** Loaded Assemblies **************
        Assembly Version: 1.0.5000.0
        Win32 Version: 1.1.4322.573
        CodeBase: file:///c:/winnt/microsoft.net/framework/v1.1.4322/mscorlib.dll
        Assembly Version: 1.0.3084.28625
        Win32 Version: 1.0.3084.28625
        CodeBase: file:///C:/Documents%20and%20Settings/Administrator/My%20Documents/Visual%20Studio%20Projects/WindowsApplication3/bin/Debug/WindowsApplication3.exe
        Assembly Version: 1.0.5000.0
        Win32 Version: 1.1.4322.573
        CodeBase: file:///c:/winnt/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
        Assembly Version: 1.0.5000.0
        Win32 Version: 1.1.4322.573
        CodeBase: file:///c:/winnt/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
        Assembly Version: 1.0.5000.0
        Win32 Version: 1.1.4322.573
        CodeBase: file:///c:/winnt/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
        Assembly Version: 1.0.5000.0
        Win32 Version: 1.1.4322.573
        CodeBase: file:///c:/winnt/assembly/gac/system.xml/1.0.5000.0__b77a5c561934e089/system.xml.dll
        Assembly Version:
        Win32 Version:
        CodeBase: file:///c:/winnt/assembly/gac/sybase.data.aseclient/
        Assembly Version: 1.0.5000.0
        Win32 Version: 1.1.4322.573
        CodeBase: file:///c:/winnt/assembly/gac/system.data/1.0.5000.0__b77a5c561934e089/system.data.dll

    ************** JIT Debugging **************
    To enable just in time (JIT) debugging, the config file for this
    application or machine (machine.config) must have the
    jitDebugging value set in the system.windows.forms section.
    The application must also be compiled with debugging

    For example:

        <system.windows.forms jitDebugging="true" />

    When JIT debugging is enabled, any unhandled exception
    will be sent to the JIT debugger registered on the machine
    rather than being handled by this dialog.

    when i try to use this connection 

       AseConnection lsybaseCon;
       AseCommand lsybaseCmd;
       AseDataAdapter lsybaseAdapter;
       DataSet lds = new DataSet();
       string lstrQuery = "select count(*) from products..PRODUCT_SYSTEM_PATH" ;
    lsybaseCon = new AseConnection("Data Source='';Port=;database= ;uid=database;pwd=database1");
       lsybaseCmd = new AseCommand(lstrQuery, lsybaseCon);
       lsybaseAdapter = new AseDataAdapter(lsybaseCmd);


    i get invalid port number (btw what is the port number?)

    hope you guys can help

    Sunday, June 15, 2008 8:15 AM

All replies

  • Nevermind guys,
    i managed to get the connection working
    here is the code if someone needs it.

       AseConnection oAseConn = new AseConnection();
       oAseConn.ConnectionString = "Data Source=IP/host;" +
        "Port=port number;" +
        "User ID=username;" +

       AseCommand cmd2 = oAseConn.CreateCommand();
       cmd2.CommandText = "select count(*) from products";
       Object obj2 = cmd2.ExecuteScalar();
       label5.Text = obj2.ToString();



    Sunday, June 15, 2008 12:22 PM

    Can someone please assist me in getting a prvoider .DLL so i can connect to a Sybase database please ?!

    Or is these a generic type provider i can use to make a connection ?!



    Regards in advance


    Friday, August 29, 2008 5:10 AM
  • To get provider installed you need to install Sybase Client tools. It will install all providers/drivers, including .NET one.


    Friday, August 29, 2008 9:52 AM

    I am basically New to .Net i was working wth SYBASE

    Can u pls help me out in wat all dll's i need to include for connection i need to connect thru ADO.Net to Sybase12.5

    Wednesday, October 29, 2008 10:45 AM
  • If I remember correctly yuou need to install Sybase SDK that contains .NET dll files. After that you need to open .NET project to Syabse .NET provider. I believe name of the DLL starts with Sybase.Data.AseClient

    Thursday, October 30, 2008 2:17 PM