locked
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=10.162.2.11;" +
                                "Initial Catalog=;" +
                                "User ID=database;" +
                                "Password=database1";
           oAseConn.Open();


    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 **************
    mscorlib
        Assembly Version: 1.0.5000.0
        Win32 Version: 1.1.4322.573
        CodeBase: file:///c:/winnt/microsoft.net/framework/v1.1.4322/mscorlib.dll
    ----------------------------------------
    WindowsApplication3
        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
    ----------------------------------------
    System.Windows.Forms
        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
    ----------------------------------------
    System
        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
    ----------------------------------------
    System.Drawing
        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
    ----------------------------------------
    System.Xml
        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
    ----------------------------------------
    Sybase.Data.AseClient
        Assembly Version: 1.15.50.0
        Win32 Version: 1.15.50.0
        CodeBase: file:///c:/winnt/assembly/gac/sybase.data.aseclient/1.15.50.0__26e0f1529304f4a7/sybase.data.aseclient.dll
    ----------------------------------------
    System.Data
        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
    enabled.

    For example:

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

    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='10.162.2.11';Port=;database= ;uid=database;pwd=database1");
       lsybaseCmd = new AseCommand(lstrQuery, lsybaseCon);
       lsybaseAdapter = new AseDataAdapter(lsybaseCmd);
       lsybaseAdapter.Fill(lds);

     

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

    hope you guys can help

    regards,
    Yoni
    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.

    [code]
       AseConnection oAseConn = new AseConnection();
       oAseConn.ConnectionString = "Data Source=IP/host;" +
        "Port=port number;" +
        "User ID=username;" +
        "Password=password";
       oAseConn.Open();

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


    [/code]

     

    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

    Kane

    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