0

I'm working on a C# application, based on Telerik's OpenAccess technology.

The following piece of source code does not give any results (although the corresponding table contains a lot of data):

List<Setting> lijst = new List<Setting>();
try { 
    lijst = database.GetData<Setting>().ToList();
}
catch (Exception e)
{
    log.Error($"Exception: [{e}], Message=[{e.Message}]");
}
log.Debug($"Count=[{lijst.Count()}]");

However, the following piece of source code (from another, similar program) does give results:

internal static IEnumerable<Lift> GetAll(IDatabaseConnection database)
{  
    return database.GetData<Lift>();
}

The only difference is can find, are the connectionstrings (according to the watch-windows):

  • Non-working application : "Data Source=localhost\\SQLEXPRESS;..."
  • Working application : "Data Source=localhost\SQLEXPRESS;..."

As you can see, one contains a single backslash, the other a double one.

However, both strings are created the same way:

  • Non-working application : Settings.DatabaseAddress = @"localhost\SQLEXPRESS";
  • Working application : Settings.DatabaseAddress = @"localhost\SQLEXPRESS";

Am I on the right track and are those single/double characters indeed an indication, explaining the wrong database behaviour, or am I on the wrong track here?

For your information: I'm working with Visual Studio 2022, version 17.5.5.

9
  • 1
    The following piece of source code does not give any results is not the same as not connecting in the first place. Commented May 30, 2023 at 12:49
  • 1
    If the connection was truly the problem, you'd be getting an error, not an empty result set. Are you getting an error, or is your local database/table just empty? Note that the pieces of code you quote are not attempting to retrieve the same table. Commented May 30, 2023 at 12:50
  • Who knows, you gave way too little info in some code snippets, why not just debug the code and follow the money Commented May 30, 2023 at 12:55
  • @siggemannen: that's the problem: the DatabaseAddress entries are used somewhere inside the Telerik "OpenAccess" source code, so I don't see what's happening there. I can tell you that my source code does not generate an exception (hence the try-catch construction). Commented May 30, 2023 at 12:57
  • well, if you have a watch, you can set a breakpoint when the value changes, so you can track when it gets this extra slash Commented May 30, 2023 at 13:10

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.