Xantres
Xantres
CC#
Created by Xantres on 9/23/2024 in #help
CS0050: Inconsistent Accessibility
Thanks, that worked!
10 replies
CC#
Created by Xantres on 9/23/2024 in #help
CS0050: Inconsistent Accessibility
Does it also need to be public?
10 replies
CC#
Created by Xantres on 9/23/2024 in #help
CS0050: Inconsistent Accessibility
Term is "internal class term"
10 replies
CC#
Created by Xantres on 4/28/2024 in #help
Database function skipping data
Okay, so I have changed the above to what I have and that worked, thanks for your direction.
9 replies
CC#
Created by Xantres on 4/28/2024 in #help
Database function skipping data
I am working on this for a school project and have to use a virtual machine so I can't copy code from it to my machine
9 replies
CC#
Created by Xantres on 4/28/2024 in #help
Database function skipping data
Sorry, I miss typed the variable, it is users
9 replies
CC#
Created by Xantres on 4/24/2024 in #help
MySql Syntax error
Thank you for your time @Jimmacle, I appreciate the direction you provided.
26 replies
CC#
Created by Xantres on 4/24/2024 in #help
MySql Syntax error
I apologize for my apparent ignorance, I am currently in school learning C#
26 replies
CC#
Created by Xantres on 4/24/2024 in #help
MySql Syntax error
and I got a fatal error during execution
26 replies
CC#
Created by Xantres on 4/24/2024 in #help
MySql Syntax error
so I changed out my original string with this:
C#
string updateName = @"UPDATE client_schedule.customer SET customerName = '@customer.CustomerName' WHERE customerId = @customer.CustomerID ";
C#
string updateName = @"UPDATE client_schedule.customer SET customerName = '@customer.CustomerName' WHERE customerId = @customer.CustomerID ";
26 replies
CC#
Created by Xantres on 4/24/2024 in #help
MySql Syntax error
thanks!
26 replies
CC#
Created by Xantres on 4/24/2024 in #help
MySql Syntax error
or do I need to break out the object perameters into separate variables before using them in the string?
26 replies
CC#
Created by Xantres on 4/24/2024 in #help
MySql Syntax error
So with parameterized queries, if I have an object as a perameter, I could do something like "@customer.CustomerID"
26 replies
CC#
Created by Xantres on 4/24/2024 in #help
MySql Syntax error
So you need a space after the end of the Where clause?
26 replies
CC#
Created by Xantres on 4/24/2024 in #help
MySql Syntax error
I have printed it out and have reviewed the MySql manual, but am not seeing a difference, can you point out where my mistake is other then the vulnerable code?
26 replies
CC#
Created by Xantres on 4/24/2024 in #help
MySql Syntax error
is that when you use the @ symbol?
26 replies
CC#
Created by Xantres on 9/22/2023 in #help
❔ Help with TargetInvocationException when creating trace switch
I appreciate your advice, but I am still learning, been following a book and am trying to create a foundation I can work on. If you could please just diagnose the code that is written so I can learn from that and be able to move forward, it would be much appreciated.
15 replies
CC#
Created by Xantres on 9/22/2023 in #help
❔ Help with TargetInvocationException when creating trace switch
Program.cs:
using System.Diagnostics;
using Microsoft.Extensions.Configuration;

string logPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "log.txt");

WriteLine($"Writing to: {logPath}");

TextWriterTraceListener logFile = new(File.CreateText(logPath));

Trace.Listeners.Add(logFile);

// text writer is buffered, so this option calls
// Flush() on all listeners after writing

Trace.AutoFlush = true;

Debug.WriteLine("Debug says, I am watching!");
Trace.WriteLine("Trace says, I am watching!");

WriteLine("Reading from appsettings.json in {0}",
arg0: Directory.GetCurrentDirectory());

ConfigurationBuilder builder = new();

builder.SetBasePath(Directory.GetCurrentDirectory());

builder.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

IConfigurationRoot configuration = builder.Build();

TraceSwitch ts = new(
displayName: "PacktSwitch",
description: "This switch is set via a JSON config.");

configuration.GetSection("PacktSwitch").Bind(ts); // Exception happens here.

Trace.WriteLineIf(ts.TraceError, "Trace error");
Trace.WriteLineIf(ts.TraceWarning, "Trace warning");
Trace.WriteLineIf(ts.TraceInfo, "Trace information");
Trace.WriteLineIf(ts.TraceVerbose, "Trace verbose");

//int unitsInStock = 12;
//LogSourceDetails(unitsInStock > 10);

ReadLine();
using System.Diagnostics;
using Microsoft.Extensions.Configuration;

string logPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "log.txt");

WriteLine($"Writing to: {logPath}");

TextWriterTraceListener logFile = new(File.CreateText(logPath));

Trace.Listeners.Add(logFile);

// text writer is buffered, so this option calls
// Flush() on all listeners after writing

Trace.AutoFlush = true;

Debug.WriteLine("Debug says, I am watching!");
Trace.WriteLine("Trace says, I am watching!");

WriteLine("Reading from appsettings.json in {0}",
arg0: Directory.GetCurrentDirectory());

ConfigurationBuilder builder = new();

builder.SetBasePath(Directory.GetCurrentDirectory());

builder.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

IConfigurationRoot configuration = builder.Build();

TraceSwitch ts = new(
displayName: "PacktSwitch",
description: "This switch is set via a JSON config.");

configuration.GetSection("PacktSwitch").Bind(ts); // Exception happens here.

Trace.WriteLineIf(ts.TraceError, "Trace error");
Trace.WriteLineIf(ts.TraceWarning, "Trace warning");
Trace.WriteLineIf(ts.TraceInfo, "Trace information");
Trace.WriteLineIf(ts.TraceVerbose, "Trace verbose");

//int unitsInStock = 12;
//LogSourceDetails(unitsInStock > 10);

ReadLine();
15 replies
CC#
Created by Xantres on 9/22/2023 in #help
❔ Help with TargetInvocationException when creating trace switch
Instrumenting.csproj:
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.4" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
<Using Include="System.Console" Static="true" />
</ItemGroup>

<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.4" />
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
</ItemGroup>

<ItemGroup>
<Using Include="System.Console" Static="true" />
</ItemGroup>

<ItemGroup>
<None Update="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
15 replies
CC#
Created by Xantres on 9/22/2023 in #help
❔ Help with TargetInvocationException when creating trace switch
appsettings.json:
{
"PacktSwitch": {
"Level": "Info"
}
}
{
"PacktSwitch": {
"Level": "Info"
}
}
15 replies