Can't connect to the DB

I am running the Sample C# Project and getting the following error. Please help.

Avontus.Core.DataPortalException: ‘DataPortal.Update failed (System.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) —> System.ComponentModel.Win32Exception (0x80004005): The system cannot find the file specified
at System.Data.SqlClient.SqlInternalConnectionTds…ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1 retry)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource1 retry) at System.Data.SqlClient.SqlConnection.Open() at Avontus.Core.Data.ConnectionManager1.GetManager(String database, Boolean isDatabaseName, String label)
at Avontus.Rental.Library.Utility.DbUtil.GetConnectionManager()
at Avontus.Rental.Library.Security.AuthenticateUserCommand.DataPortal_Execute()
at dm(Object , Object )
at Avontus.Core.Reflection.MethodCaller.CallMethod(Object obj, DynamicMethodHandle methodHandle, Object parameters)
ClientConnectionId:00000000-0000-0000-0000-000000000000
Error Number:2,State:0,Class:20)’

Hello mlitz. This is an issue with the connection string. Have you installed Quantify and successfully connected on the computer that you’re running the code from?

Yes I have, I can access Quantify fine from this computer.

Try running your code by adding a reference to the dll’s from the install folder. This will force the code to use the connection string from there. Since you’re connected via Quantify that should work.

And turn ‘copy local’ off on those references.

Quant Issue
I have added all 3 dll references to the install folder and set ‘copy local’ off on all 3, see attached.

Now it’s giving me this:
System.IO.FileNotFoundException: ‘Could not load file or assembly ‘Avontus.Rental.Library, Version=9.0.1753.129, Culture=neutral, PublicKeyToken=null’ or one of its dependencies. The system cannot find the file specified.’

If I set the 'copy local’s back to true I get the first error.

That would indicate that you haven’t included the reference for Avontus.Rental.Library.dll, or there’s an issue with it if so. If you have a reference for it, remove it and re-add it. That should fix it.

Quant Issue

I have added it though, see attached. I’ve deleted it an referenced it, no help.

Maybe I’m doing something wrong because this doesn’t seem to difficult. Let me quickly explain.

Quantify is working fine on my computer.
I d/l the C# sample project, unzipped it and put it in a folder.
Then opened it in visual studio.
Right clicked the main project in the solution explorer and wend Add > Referance.
I found the 3 dlls in (C:\Program Files\Avontus\Quantify Client) and clicked ok - the 3 now show up in reference folder (see attached)
Then i changed this line of code:
bool success = AvontusPrincipal.Login(“admin”, “password”);
So it has my log in information.
Then ran the project and get the first error or the second error depending on if ‘copy local’ is checked or not.

Am I missing something??

Thanks

Are you still getting the same error or is it different now? Compiler error now?
A network-related or instance-specific error occurred while establishing a connection to SQL Server.

I’m getting the same errors as I posted above. If ‘copy local’ is off, it can’t find the dll and if its on it can’t connect to the database.

Hello mlitz. I have downloaded the sample code, set the references and have successfully run the sample app. Maybe start from scratch…

I may have misguided you on the copy local, you can keep that to True

First, on your local machine, install and log into Quantify.

Second:

  1. Download the sample c# code (make sure to unblock the zip file)
  2. Set the login credentials on line 38 to your credentials
  3. Set the references to the missing dll’s in C:\Program Files\Avontus\Quantify Client
  4. Put a breakpoint on line 38
  5. Run the code

You should be able to jump to the next line after the breakpoint is hit.

I can’t for the life of me get it to work, looking on this forum it seems another person had my same issue and the answer was:

Hello. You have not set up on the permissions correctly on your installation of SQL Server. Instructions are here:

https://docs.avontus.com/display/QUAN/Step+2%3A+Install+SQL+Server+2017+Express

But the link is broken.

I really need to get this API connection up and running, let me know.

Thanks

That link is for SQL Server 2017. If you search the help docs site you’ll find the same article for SQL 2022. However, since you can connect to your SQL Server locally, from a locally installed Quantify, I’m not sure this will solve your issue.
https://docs.avontus.com/docs/step-2-install-sql-server-2022-express

The most common fix for your issue is usually ensuring SQL Server services are running and Named Pipes/TCP-IP protocols are enabled in SQL Server Configuration Manager, followed by a service restart.

  1. Verify SQL Server Service Status
  • Check if SQL Server service is running on the database server
  • Also check SQL Server Browser service (required for named instances)
    Services to verify: SQL Server (MSSQLSERVER) or SQL Server (InstanceName) and SQL Server Browser
  1. Check Connection String Configuration
  • Verify the server name/instance name in the connection string
  • Common formats:
    • ServerName (default instance)
    • ServerName\InstanceName (named instance)
    • ServerName,Port (specific port)
  1. Network Connectivity
  • Test basic network connectivity: ping [ServerName] from client machine
  • Try connecting with SQL Server Management Studio from the client machine
  • Check if you can telnet to SQL Server port: telnet [ServerName] 1433
  1. SQL Server Configuration
  • Enable TCP/IP and Named Pipes in SQL Server Configuration Manager
  • Restart SQL Server service after making changes
  • Verify SQL Server is configured to allow remote connections:
    • SQL Server Management Studio → Server Properties → Connections → “Allow remote connections to this server”
  1. Firewall Settings
  • Windows Firewall may be blocking SQL Server ports
  • Default port 1433 for default instance
  • Dynamic ports for named instances (check SQL Server Configuration Manager)
  • Consider temporarily disabling firewall to test
  1. Named Pipes Specific Issues
  • Since the error mentions “Named Pipes Provider”:
  • Enable Named Pipes protocol in SQL Server Configuration Manager
  • Ensure Named Pipes pipe name is correct (usually \.\pipe\sql\query)
  • Try changing connection string to use TCP/IP instead: add Network Library=DBMSSOCN; or use tcp: prefix
  1. Quick Diagnostic Steps
  • Test from database server itself - can the application connect when run directly on the SQL Server machine?
  • Try different connection protocols - modify connection string to force TCP/IP
  • Check SQL Server error logs - look for additional clues about connection attempts
  • Use SQL Server Configuration Manager - verify all protocols are enabled and services are running