Topic
  • 7 replies
  • Latest Post - ‏2012-11-15T21:55:44Z by SystemAdmin
SystemAdmin
SystemAdmin
115 Posts

Pinned topic Connecting to SolidDB from .NET application without using a system DSN

‏2012-10-15T15:19:47Z |
I'm trying to connect to a SOLID DB system from a .NET application written in C# without using a DSN configured on the Windows PC running the application. I've tried various ODBC connection string formats but none of them have worked. Has anyone used the System.Data.Odbc.OdbcConnection object to connect to a SOLID DB running on a separate server without a system DSN?

My latest attempt at a connection string looks like this: Driver={Solid Database Engine 04.00.0042};DSN=tcp 192.169.1.100 1234;UID=user;PWD=password

The SOLID DB ODBC driver we're using is SOLID ODBC DRIVER 4.0 – (ANSI) and the driver name displays as: Solid Database Engine 04.00.0042

Thanks for any help you can provide!

Steve
Updated on 2012-11-15T21:55:44Z at 2012-11-15T21:55:44Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    115 Posts

    Re: Connecting to SolidDB from .NET application without using a system DSN

    ‏2012-11-01T19:51:14Z  
    Hi,

    I've never tried to use solidDB with .NET but perhaps you need to have a solid.ini file with the data source information.

    Eg. solid.ini

    
    [data sources] solid_dsn = tcp 192.169.1.100 1234
    


    Also seems to me that the connection string you give to OdbcConnection constructor uses the name of the driver so I'd try this:
    
    Driver=
    {SOLID ODBC DRIVER 4.0 - (ANSI)
    };DSN=solid_dsn;UID=user;PWD=password
    


    Hope this helps. The driver unfortunately is not very helpful when trying to get connected.

    Mikko
  • SystemAdmin
    SystemAdmin
    115 Posts

    Re: Connecting to SolidDB from .NET application without using a system DSN

    ‏2012-11-12T12:24:02Z  
    Hi,

    I've never tried to use solidDB with .NET but perhaps you need to have a solid.ini file with the data source information.

    Eg. solid.ini

    <pre class="jive-pre"> [data sources] solid_dsn = tcp 192.169.1.100 1234 </pre>

    Also seems to me that the connection string you give to OdbcConnection constructor uses the name of the driver so I'd try this:
    <pre class="jive-pre"> Driver= {SOLID ODBC DRIVER 4.0 - (ANSI) };DSN=solid_dsn;UID=user;PWD=password </pre>

    Hope this helps. The driver unfortunately is not very helpful when trying to get connected.

    Mikko
    Mikko,

    Thank you for your helpful insight. It has allowed me to make some progress on the problem. Now that I'm using the correct driver name the exception message has changed and there is a long delay before it occurs (like a timeout). I've tried to figure out how to use a solid.ini file. It isn't clear to me where the file must exist when I'm connecting to SOLID from a web service hosted in IIS on a Windows server. My connection string follows the pattern you suggested except the DSN part.

    Here is the connection string:
    Driver={SOLID ODBC DRIVER 4.0 – (ANSI)};DSN=tcp 192.169.1.100 1234;UID=user;PWD=password

    Here is the exception I'm getting now:
    OdbcException ERROR HY000 SOLID Communication Error 21306: Server 'NmPipe SOLID' not found, connection failed

    My suspicion is that the SOLID driver doesn't like what I specified for DSN and is falling back to a default behavior of assuming there is a local SOLID instance that can be accessed through named pipes. My ideal solution is to not use a solid.ini file to avoid a more complex deployment scenario. Does this new error message give you any other ideas for me to try?

    Thanks again for your help!

    Steve
  • SystemAdmin
    SystemAdmin
    115 Posts

    Re: Connecting to SolidDB from .NET application without using a system DSN

    ‏2012-11-13T09:24:46Z  
    Mikko,

    Thank you for your helpful insight. It has allowed me to make some progress on the problem. Now that I'm using the correct driver name the exception message has changed and there is a long delay before it occurs (like a timeout). I've tried to figure out how to use a solid.ini file. It isn't clear to me where the file must exist when I'm connecting to SOLID from a web service hosted in IIS on a Windows server. My connection string follows the pattern you suggested except the DSN part.

    Here is the connection string:
    Driver={SOLID ODBC DRIVER 4.0 – (ANSI)};DSN=tcp 192.169.1.100 1234;UID=user;PWD=password

    Here is the exception I'm getting now:
    OdbcException ERROR HY000 SOLID Communication Error 21306: Server 'NmPipe SOLID' not found, connection failed

    My suspicion is that the SOLID driver doesn't like what I specified for DSN and is falling back to a default behavior of assuming there is a local SOLID instance that can be accessed through named pipes. My ideal solution is to not use a solid.ini file to avoid a more complex deployment scenario. Does this new error message give you any other ideas for me to try?

    Thanks again for your help!

    Steve
    Hi Steve,

    That error message is saying that it tries to connect using the default Solid connect string (nmp solid) and it cannot. Which for us means that the driver is not getting the DSN part of the connection string you are using, like you suspected.

    I don't really know how the connection string should be formed so that you didn't need a solid.ini file. I am not sure it is possible.

    With a solid.ini this might help though:

    
    [Com] Connect = tcp 192.169.1.100 1234
    


    (See Client side configuration file)

    The driver looks for solid.ini in the current working directory of the process (what you'd get in C# with the GetCurrentDirectory() method of the Directory class). You can also set the environment variable SOLIDDIR to point to the directory where you have solid.ini. I am not sure if SOLIDDIR exists in 4.0 but give it a try.

    Mikko
  • SystemAdmin
    SystemAdmin
    115 Posts

    Re: Connecting to SolidDB from .NET application without using a system DSN

    ‏2012-11-13T10:07:30Z  
    Hi Steve,

    That error message is saying that it tries to connect using the default Solid connect string (nmp solid) and it cannot. Which for us means that the driver is not getting the DSN part of the connection string you are using, like you suspected.

    I don't really know how the connection string should be formed so that you didn't need a solid.ini file. I am not sure it is possible.

    With a solid.ini this might help though:

    <pre class="jive-pre"> [Com] Connect = tcp 192.169.1.100 1234 </pre>

    (See Client side configuration file)

    The driver looks for solid.ini in the current working directory of the process (what you'd get in C# with the GetCurrentDirectory() method of the Directory class). You can also set the environment variable SOLIDDIR to point to the directory where you have solid.ini. I am not sure if SOLIDDIR exists in 4.0 but give it a try.

    Mikko
    When trying to get the DSN in the Driver string working, you might want to try first with the following solid.ini to enable tracing:

    
    [Com] Trace = Yes
    


    This should cause any connection attempt to output information into soltrace.out, which will tell you what kind of a DSN/connect string the driver received and tried to parse.

    Eg.

    
    Parsing address 
    'foo bar'. Protocol 
    'foo' unrecognised or not supported. SOLID Communication Error 21300: Protocol 
    'foo' is not supported. Most likely the protocol name in the connect string is misspelled. Check the connect string..
    
  • SystemAdmin
    SystemAdmin
    115 Posts

    Re: Connecting to SolidDB from .NET application without using a system DSN

    ‏2012-11-13T21:39:02Z  
    When trying to get the DSN in the Driver string working, you might want to try first with the following solid.ini to enable tracing:

    <pre class="jive-pre"> [Com] Trace = Yes </pre>

    This should cause any connection attempt to output information into soltrace.out, which will tell you what kind of a DSN/connect string the driver received and tried to parse.

    Eg.

    <pre class="jive-pre"> Parsing address 'foo bar'. Protocol 'foo' unrecognised or not supported. SOLID Communication Error 21300: Protocol 'foo' is not supported. Most likely the protocol name in the connect string is misspelled. Check the connect string.. </pre>
    Mikko,

    For testing I setup a solid.ini file with the trace value set to Yes. It looks like it is ignoring the value I specify for DSN in the connection string. If the value of DSN is an actual system DSN configured in Windows then the soltrace.out file shows how it is connecting properly.

    Below is an excerpt from the soltrace.out file generated when I used the following connection string:
    Driver={SOLID ODBC DRIVER 4.0 - (ANSI)};DSN=tcp 192.169.1.100 1234;UID=user;PWD=password

    soltrace.out contents:

    Tue Nov 13 16:17:49 2012
    Version: 04.00.0042
    Operating system: Windows NT 6.1 ix86 MT

    Reading communication configuration from file C:\Users\...\solid.ini.

    Scanning connect information.
    Connect info not found, generating default.

    Parsing address 'NmPipe SOLID'.
    Address information:
    fullname : 'NmPipe SOLID'
    lisname : 'SOLID'
    protocol : 'nmp' (NmPipe)
    enabled : Yes
    ping : 0
    trace : No

    Parsing address 'NmPipe SOLID'.
    Address information:
    fullname : 'NmPipe SOLID'
    lisname : 'SOLID'
    protocol : 'nmp' (NmPipe)
    enabled : Yes
    ping : 0
    trace : No

    Initialising protocol 'nmp' (NmPipe).
    Searching DLL 'SNPW3240'.
    DLL C:\Windows\system32\SNPW3240.DLL loaded.
    SOLID version 04.00.0042, DLL interface version 4.
    Build information Mon Dec 29 12:15:29 2003.
    Initialisation of protocol 'nmp' succeeded.

    Protocol NmPipe using configuration :
    MaxPhysMsgLen: 8192
    ReadBufSize: 2048
    WriteBufSize: 2048
    SelectThread: Yes
    Trace: Yes
    MinWritePoolBuffers: 4
    MaxWritePoolBuffers: -1
    WritePoolIncrement: 1
    SyncRead: No
    SyncWrite: No

    13.11 16:17:49 Initialising client. Connect info 'NmPipe SOLID'.
    Establishing connection to server 'NmPipe SOLID'.
    Connecting failed (rc=-20006). NmPipe error 2.
    SOLID Communication Error 21306: Server 'NmPipe SOLID' not found, connection failed.

    Thanks for your help!

    Steve
  • SystemAdmin
    SystemAdmin
    115 Posts

    Re: Connecting to SolidDB from .NET application without using a system DSN

    ‏2012-11-15T13:24:11Z  
    Mikko,

    For testing I setup a solid.ini file with the trace value set to Yes. It looks like it is ignoring the value I specify for DSN in the connection string. If the value of DSN is an actual system DSN configured in Windows then the soltrace.out file shows how it is connecting properly.

    Below is an excerpt from the soltrace.out file generated when I used the following connection string:
    Driver={SOLID ODBC DRIVER 4.0 - (ANSI)};DSN=tcp 192.169.1.100 1234;UID=user;PWD=password

    soltrace.out contents:

    Tue Nov 13 16:17:49 2012
    Version: 04.00.0042
    Operating system: Windows NT 6.1 ix86 MT

    Reading communication configuration from file C:\Users\...\solid.ini.

    Scanning connect information.
    Connect info not found, generating default.

    Parsing address 'NmPipe SOLID'.
    Address information:
    fullname : 'NmPipe SOLID'
    lisname : 'SOLID'
    protocol : 'nmp' (NmPipe)
    enabled : Yes
    ping : 0
    trace : No

    Parsing address 'NmPipe SOLID'.
    Address information:
    fullname : 'NmPipe SOLID'
    lisname : 'SOLID'
    protocol : 'nmp' (NmPipe)
    enabled : Yes
    ping : 0
    trace : No

    Initialising protocol 'nmp' (NmPipe).
    Searching DLL 'SNPW3240'.
    DLL C:\Windows\system32\SNPW3240.DLL loaded.
    SOLID version 04.00.0042, DLL interface version 4.
    Build information Mon Dec 29 12:15:29 2003.
    Initialisation of protocol 'nmp' succeeded.

    Protocol NmPipe using configuration :
    MaxPhysMsgLen: 8192
    ReadBufSize: 2048
    WriteBufSize: 2048
    SelectThread: Yes
    Trace: Yes
    MinWritePoolBuffers: 4
    MaxWritePoolBuffers: -1
    WritePoolIncrement: 1
    SyncRead: No
    SyncWrite: No

    13.11 16:17:49 Initialising client. Connect info 'NmPipe SOLID'.
    Establishing connection to server 'NmPipe SOLID'.
    Connecting failed (rc=-20006). NmPipe error 2.
    SOLID Communication Error 21306: Server 'NmPipe SOLID' not found, connection failed.

    Thanks for your help!

    Steve
    I did some digging and it seems that the DSN keyword gets eaten by Driver Manager when you also specify the DRIVER keyword. This seems to be by design, as they are possibly redundant or conflicting information (but surely the driver could decide which piece of information it should use...). Anyway, because of this, Solid driver does not actually receive the DSN attribute and thus cannot connect using the connect string.

    Apparently it can be only DRIVER or DSN. In my testing, if DRIVER is first, DSN is removed. If DSN is first, DRIVER is left intact, but since the first one takes precedence, this does not help us.

    These work:

    
    Driver=
    {SOLID ODBC DRIVER 4.0 - (ANSI)
    };UID=dba;PWD=pw
    

    or
    
    DSN=my_solid;UID=dba;PWD=pw
    


    Trouble is, neither allows you to use a direct address for connecting. First one requires you to have solid.ini file that contains Com.Connect setting to tell where to connect. Second one relies on the data source to specify driver and connect string (but you don't need a solid.ini).

    I don't know if there's any way to prevent the Driver Manager from removing DSN if DRIVER is present, but that would help.

    Mikko
  • SystemAdmin
    SystemAdmin
    115 Posts

    Re: Connecting to SolidDB from .NET application without using a system DSN

    ‏2012-11-15T21:55:44Z  
    I did some digging and it seems that the DSN keyword gets eaten by Driver Manager when you also specify the DRIVER keyword. This seems to be by design, as they are possibly redundant or conflicting information (but surely the driver could decide which piece of information it should use...). Anyway, because of this, Solid driver does not actually receive the DSN attribute and thus cannot connect using the connect string.

    Apparently it can be only DRIVER or DSN. In my testing, if DRIVER is first, DSN is removed. If DSN is first, DRIVER is left intact, but since the first one takes precedence, this does not help us.

    These work:

    <pre class="jive-pre"> Driver= {SOLID ODBC DRIVER 4.0 - (ANSI) };UID=dba;PWD=pw </pre>
    or
    <pre class="jive-pre"> DSN=my_solid;UID=dba;PWD=pw </pre>

    Trouble is, neither allows you to use a direct address for connecting. First one requires you to have solid.ini file that contains Com.Connect setting to tell where to connect. Second one relies on the data source to specify driver and connect string (but you don't need a solid.ini).

    I don't know if there's any way to prevent the Driver Manager from removing DSN if DRIVER is present, but that would help.

    Mikko
    Mikko,

    Thanks for continuing to look into this issue with me. I think based on your findings and some reading I've been doing on the MSDN ODBC programmers guide, I must admit defeat on this adventure. Your assessment of the Driver Manager behavior is consistent with how MSDN documented it here: http://msdn.microsoft.com/en-us/library/windows/desktop/ms715433(v=vs.85).aspx.

    My next step is figuring out how to manage and deploy solid.ini files to all of the client systems.

    Thanks again for your help, I am very grateful.

    Steve