Click here to Skip to main content
15,887,027 members
Home / Discussions / C#
   

C#

 
GeneralRe: Google PeopleAPI & HttpListener Redirect URI Pin
Kevin Marois25-Jun-23 17:41
professionalKevin Marois25-Jun-23 17:41 
GeneralRe: Google PeopleAPI & HttpListener Redirect URI Pin
jschell26-Jun-23 5:31
jschell26-Jun-23 5:31 
GeneralRe: Google PeopleAPI & HttpListener Redirect URI Pin
Kevin Marois26-Jun-23 8:20
professionalKevin Marois26-Jun-23 8:20 
GeneralRe: Google PeopleAPI & HttpListener Redirect URI Pin
Kevin Marois26-Jun-23 16:19
professionalKevin Marois26-Jun-23 16:19 
GeneralRe: Google PeopleAPI & HttpListener Redirect URI Pin
jschell27-Jun-23 4:48
jschell27-Jun-23 4:48 
General[UPDATE] - Google PeopleAPI & HttpListener Redirect URI Pin
Kevin Marois27-Jun-23 6:01
professionalKevin Marois27-Jun-23 6:01 
GeneralRe: [UPDATE] - Google PeopleAPI & HttpListener Redirect URI Pin
jschell28-Jun-23 5:54
jschell28-Jun-23 5:54 
QuestionThreading related naming and usage of const Pin
HobbyProggy20-Jun-23 5:04
professionalHobbyProggy20-Jun-23 5:04 
Hey guys,

i was facing an error on my logging today which made me struggle a bit.
To clarify the issue i wanted to know if anyone knows such things happen on a regular basis or is just bad luck.

We are within a REST Endpoint where multiple users fire requests to, the Endpoint will then process all these requests async and return the results.

There problem happened here (i narrowed it down to the important parts and underlined them):

private ProjectInformationBase? GetProjectBaseByDevelopmentProject(Guid idProject)
        {
            const string getProject = "SELECT * FROM Projects WHERE idProject = @idProject";

            var getProjectCommand = new SqlCommand(getProject, DbConnection);
            getProjectCommand.Parameters.Add("@idProject", SqlDbType.UniqueIdentifier).Value = idProject;

            var projectData = getProjectCommand.ReadDataByCommand();

            if (projectData.Rows.Count == 1)
            {
                return new ProjectInformationBase
                {
                    IdProjectInformationBase = (Guid)projectData.Rows[0]["idProject"], //this one crashed
                };
            }

            return null;
        }

        private ProjectInformationBase? GetProjectBaseByEcrProject(Guid idProject)
        {
            const string getEcrProject = "SELECT * FROM EcrProject WHERE ecrIdProject = @idProject";

            var getEcrProjectCommand = new SqlCommand(getEcrProject, DbConnection);
            getEcrProjectCommand.Parameters.Add("@ecrIdProject", SqlDbType.UniqueIdentifier).Value = idProject;

            var projectData = getEcrProjectCommand.ReadDataByCommand();

            if (projectData.Rows.Count == 1)
            {
                try
                {
                    return new ProjectInformationBase
                    {
                        IdProjectInformationBase = (Guid)projectData.Rows[0]["ecrIdProject"],
                    };
                }
                catch (Exception e)
                {
                    throw;
                }
            }

            return null;
        }


On the log it said the column "idProject" wasn't found, which looks to me like it was using the wrong method / sql request or dataTable "projectData". Honestly i thought since they get created and populated each time they should be "threadsafe" and not interfere with each other.

Anyone care to explain what could have happened here?

*Edit**Also filled in the blank code lines*
Please note that the "DbConnection" is defined within the class and the class is registered as Singleton.

I could not come up with a better title, but to explain what i mean by that.

The error produced was, that within the Method for getting the Development Project, the result table did not contain a column with "idProject". This error should never happen, because we only read if we have exactly 1 row and the table on the SQL Server hasn't been changed for ages, nor are there null rows inside.
What I thought of now is that if both methods being executed, for some magical reason it could happen, because of the same names for variables within both of these methods, that the development project retrieval gets the result table of the ecr project which obviously does not contain that "idProject" column.

I have no other explanation for that issue, therefore I wanted to know if someone else could have an idea where it possibly could go wrong instead.
Rules for the FOSW ![^]
MessageBox.Show(!string.IsNullOrWhiteSpace(_signature) 
    ? $"This is my signature:{Environment.NewLine}{_signature}": "404-Signature not found");


modified 21-Jun-23 5:15am.

AnswerRe: Threading related naming and usage of const Pin
Richard Deeming20-Jun-23 6:05
mveRichard Deeming20-Jun-23 6:05 
GeneralRe: Threading related naming and usage of const Pin
HobbyProggy20-Jun-23 23:02
professionalHobbyProggy20-Jun-23 23:02 
GeneralRe: Threading related naming and usage of const Pin
Richard Deeming20-Jun-23 23:26
mveRichard Deeming20-Jun-23 23:26 
GeneralRe: Threading related naming and usage of const Pin
HobbyProggy21-Jun-23 2:02
professionalHobbyProggy21-Jun-23 2:02 
GeneralRe: Threading related naming and usage of const Pin
Richard Deeming21-Jun-23 2:22
mveRichard Deeming21-Jun-23 2:22 
GeneralRe: Threading related naming and usage of const Pin
HobbyProggy21-Jun-23 3:16
professionalHobbyProggy21-Jun-23 3:16 
GeneralRe: Threading related naming and usage of const Pin
harold aptroot20-Jun-23 15:07
harold aptroot20-Jun-23 15:07 
GeneralRe: Threading related naming and usage of const Pin
HobbyProggy20-Jun-23 23:04
professionalHobbyProggy20-Jun-23 23:04 
AnswerRe: Threading related naming and usage of const Pin
Gerry Schmitz21-Jun-23 4:42
mveGerry Schmitz21-Jun-23 4:42 
AnswerRe: Threading related naming and usage of const Pin
jschell23-Jun-23 10:53
jschell23-Jun-23 10:53 
GeneralRe: Threading related naming and usage of const Pin
HobbyProggy6-Jul-23 3:55
professionalHobbyProggy6-Jul-23 3:55 
QuestionMonospaced font (i.e. "Terminal" font in FontDialog Pin
Ronald Boucher14-Jun-23 12:53
Ronald Boucher14-Jun-23 12:53 
AnswerRe: Monospaced font (i.e. "Terminal" font in FontDialog Pin
Gerry Schmitz14-Jun-23 17:34
mveGerry Schmitz14-Jun-23 17:34 
AnswerRe: Monospaced font (i.e. "Terminal" font in FontDialog Pin
jschell15-Jun-23 2:47
jschell15-Jun-23 2:47 
AnswerRe: Monospaced font (i.e. "Terminal" font in FontDialog Pin
trønderen15-Jun-23 4:15
trønderen15-Jun-23 4:15 
AnswerRe: Monospaced font (i.e. "Terminal" font in FontDialog Pin
Dave Kreskowiak15-Jun-23 7:38
mveDave Kreskowiak15-Jun-23 7:38 
GeneralRe: Monospaced font (i.e. "Terminal" font in FontDialog Pin
Richard Andrew x6415-Jun-23 14:56
professionalRichard Andrew x6415-Jun-23 14:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.