这是我的Mysql代码, 它给了一个 语法错误意外的Declare_sym
Dim SQL As String = "SELECT AES_DECRYPT(`AG_Nom`, '" & MyPass & "') AS @UserName, AES_DECRYPT(`AG_Pic`, '" & MyPass & "') AS @UserPic FROM `Agents`"
Dim command = New MySqlCommand(SQL, MySQLConn)
MySQLConn.Open()
command.Parameters.AddWithValue("@MyPass", MyPass)
Dim Reader As MySqlDataReader = command.ExecuteReader()
While Reader.Read
DataGridView1.Rows.Add(Reader.GetString("UserName"), Reader.GetString("UserPic"))
End While
MySQLConn.Close()
MySQLConn.Dispose()
请帮忙 语法错误意外的Declare_sym
答案 0 :(得分:0)
我发布的查询中没有Declare_sym
,但您的SQL代码确实存在语法错误,如下所示。在发布问题时不确定这些是否只是拼写错误
select Count(*) into regno_Count
fro students_info
^...... should be *from*
update students_info
set firstname = in_fNM,
middlename = in_mNM,
lastname = in_lNM, <----- remove this extra *,* here
where regno = in_regno ;
将您的程序正文更改为如下所示
delimiter @
create procedure StudentUpsert
(in in_regno int ,
in in_fNM varchar(50),
in in_mNM varchar(50),
in in_lNM varchar(50))
begin
declare regno_Count int ;
select Count(*) into regno_Count
from students_info;
if regno_Count > 0 then
update students_info
set firstname = in_fNM,
middlename = in_mNM,
lastname = in_lNM
where regno = in_regno ;
else
insert into students_info
values (in_regno , in_fNM , in_mNM , in_lNM);
end if;
end@