我正在尝试编写一个查询,如果用户有效,它将在另一个表中存储时间。我有第一部分,看看登录凭据是否有效。但是第二部分我不知道:获取已登录电子邮件的public org.eclipse.swt.graphics.Image getImage(Object element) {
org.eclipse.swt.graphics.Image image = null;
if ((m_column == 2)) {
image = new Image(Display.getCurrent(), getClass().getClassLoader().getResourceAsStream("icons/OpenFolder16.png"));
}
return image;
}
,然后使用此id
将其写入第二个表并在该表中插入或更新时间。>
这是我查询/存储过程的第一部分
id
这已经起作用。我尝试添加
Create Procedure spAuthenticateUser
@Email nvarchar(100),
@Wachtwoord nvarchar(100)
as
Begin
Declare @Count int
Select @Count = COUNT(Email) from Signin
where [Email] = @Email and [Wachtwoord] = @Wachtwoord
if(@Count = 1)
Begin
Select 1 as ReturnCode
End
Else
Begin
Select -1 as ReturnCode
End
End
这些是我尝试使用的表
if(@Count = 1)
Begin
Select 1 as ReturnCode
INSERT INTO Logintijd (Id, Tijd)
Select Id from Signin where [Email] = @Email
End
和
Create table Signin
(
Id int identity primary key not null,
Naam nvarchar(50) not null,
Email nvarchar(50) unique not null,
Wachtwoord nvarchar(50) not null
)
试图通过更新的类来实现
Create table Logintijd
(
Id int not null primary key,
Tijd smalldatetime not null
)
这确实会进行更新和插入,但是会为该类中的所有项目执行
我知道我必须使用 smalldatetime 和 Getdate()函数
希望这很清楚;如果没有,请告诉我。
答案 0 :(得分:0)
像您这样的声音就需要:
if(@Count = 1)
Begin
Select 1 as ReturnCode
INSERT INTO Logintijd (Id, Tijd)
Select Id, GETDATE() from Signin where [Email] = @Email
End