Click here to Skip to main content
15,867,704 members
Home / Discussions / C#
   

C#

 
GeneralRe: .NetMAUI and NAudio Pin
Gerry Schmitz15-Feb-23 13:51
mveGerry Schmitz15-Feb-23 13:51 
Questionusing cout down timer using c# Pin
Member 1592384614-Feb-23 3:44
Member 1592384614-Feb-23 3:44 
AnswerRe: using cout down timer using c# Pin
OriginalGriff14-Feb-23 4:04
mveOriginalGriff14-Feb-23 4:04 
AnswerRe: using cout down timer using c# Pin
jschell14-Feb-23 4:57
jschell14-Feb-23 4:57 
QuestionAsync functions Pin
Antti Pehkonen12-Feb-23 3:42
Antti Pehkonen12-Feb-23 3:42 
AnswerRe: Async functions Pin
Richard Deeming12-Feb-23 21:45
mveRichard Deeming12-Feb-23 21:45 
GeneralRe: Async functions Pin
Antti Pehkonen13-Feb-23 0:23
Antti Pehkonen13-Feb-23 0:23 
QuestionConverting Linq to Sql Code (SOLVED) Pin
samflex8-Feb-23 16:43
samflex8-Feb-23 16:43 
Greetings experts,

The following is a linq to sql code that I am trying to convert to for lack of a better work, regular .net framework code:

protected void updateSal_Click(object sender, EventArgs e)
        {
            newTotal.Text = theLinq.Salary.Single(s => s.Salary_Year == DateTime.Now.Year).Total_Salary.ToString();
        }


'//This is my attempted conversion to vb.net
Protected Sub updateSal_Click(ByVal sender As Object, ByVal e As EventArgs)
    Dim rowsAffected As Integer
    Dim currYear As Integer = Date.Now.Year
        Using con As New SqlConnection("server=.;database=Test;integrated security=true")
     Using cmd As New SqlCommand("UPDATE Salary Set  Total_Salary=@totsal WHERE Salary_Year = @currentYear", con)
           cmd.Parameters.Add("@totsal", SqlDbType.Decimal).Value = newTotal.Text
           cmd.Parameters.Add("@currentYear", SqlDbType.Integer).Value = currYear
           con.Open()
           rowsAffected = cmd.ExecuteNonQuery()
        End Using
       End Using
 End Sub


My result is coming up empty even though the update code works when I run it in SSMS.

Am I doing the conversion incorrectly.

modified 9-Feb-23 0:23am.

AnswerRe: Converting Linq to Sql Code Pin
Dave Kreskowiak8-Feb-23 17:35
mveDave Kreskowiak8-Feb-23 17:35 
GeneralRe: Converting Linq to Sql Code Pin
samflex8-Feb-23 17:48
samflex8-Feb-23 17:48 
GeneralRe: Converting Linq to Sql Code Pin
Dave Kreskowiak8-Feb-23 17:49
mveDave Kreskowiak8-Feb-23 17:49 
GeneralRe: Converting Linq to Sql Code Pin
samflex8-Feb-23 18:22
samflex8-Feb-23 18:22 
GeneralRe: Converting Linq to Sql Code Pin
Richard MacCutchan8-Feb-23 21:55
mveRichard MacCutchan8-Feb-23 21:55 
Questioncode smell ? C# public class with everything in it declared 'static Pin
BillWoodruff8-Feb-23 5:32
professionalBillWoodruff8-Feb-23 5:32 
AnswerRe: code smell ? C# public class with everything i it declared 'static Pin
OriginalGriff8-Feb-23 8:12
mveOriginalGriff8-Feb-23 8:12 
GeneralRe: code smell ? C# public class with everything i it declared 'static Pin
Gerry Schmitz8-Feb-23 9:04
mveGerry Schmitz8-Feb-23 9:04 
AnswerRe: code smell ? C# public class with everything in it declared 'static Pin
englebart6-Mar-23 17:22
professionalenglebart6-Mar-23 17:22 
QuestionRunning MSBuild Commands from My C# console application. Pin
Madhurima Dutta7-Feb-23 4:56
Madhurima Dutta7-Feb-23 4:56 
AnswerRe: Running MSBuild Commands from My C# console application. Pin
Dave Kreskowiak7-Feb-23 5:18
mveDave Kreskowiak7-Feb-23 5:18 
AnswerRe: Running MSBuild Commands from My C# console application. Pin
jschell7-Feb-23 9:10
jschell7-Feb-23 9:10 
GeneralRe: Running MSBuild Commands from My C# console application. Pin
Madhurima Dutta8-Feb-23 4:46
Madhurima Dutta8-Feb-23 4:46 
GeneralRe: Running MSBuild Commands from My C# console application. Pin
jschell8-Feb-23 5:07
jschell8-Feb-23 5:07 
QuestionSystem.InvalidCastException: 'Unable to cast object of type 'System.Collections.Generic.List`1[FirstMVCApplication.Models.Products]' to type 'FirstMVCApplication.Models.Products'.' Pin
Member 136517316-Feb-23 21:41
Member 136517316-Feb-23 21:41 
AnswerRe: System.InvalidCastException: 'Unable to cast object of type 'System.Collections.Generic.List`1[FirstMVCApplication.Models.Products]' to type 'FirstMVCApplication.Models.Products'.' Pin
Eddy Vluggen7-Feb-23 1:13
professionalEddy Vluggen7-Feb-23 1:13 
AnswerRe: System.InvalidCastException: 'Unable to cast object of type 'System.Collections.Generic.List`1[FirstMVCApplication.Models.Products]' to type 'FirstMVCApplication.Models.Products'.' Pin
Gerry Schmitz7-Feb-23 13:26
mveGerry Schmitz7-Feb-23 13:26 

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.