Syntax error (missing operator) in query expression '@ID = @@IDENTITY'

前端 未结 3 765
离开以前
离开以前 2021-01-26 05:57

I have given valuable advise from here

But as subject title says I am receiving error in the btnLogin method, related to my previous question but really the same problem

3条回答
  •  时光说笑
    2021-01-26 06:45

    It appears that you may have an error in your code. You set the Text of the cmd to the first line, then completely replace it with the second one:

    cmd.CommandText = "INSERT INTO LoginLogTable (UserName, LoggedInDate, LoggedInTime) VALUES (@UserName, @LoggedInDate, @LoggedInTime)";
    cmd.CommandText = "SELECT @ID = @@IDENTITY"; 
    

    So you are effectively only executing:

    cmd.CommandText = "SELECT @ID = @@IDENTITY"; 
    

提交回复
热议问题