Asked Apr 25th, 12:15 p.m. 76 0 1
  • 76 0 1
0

wrong query.You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near

Share
  • 76 0 1

có pro nào chuyên c# query mysql ko ạ , cho mình hỏi chút được ko ? mình có đoạn code ntn để lệnh vào mysql

public bool InsertGuildShare(string RoleName, int RoleID, double Share, int GuildID, int Rank, int FamilyID, string FamilyName)
{
MySQLConnection conn = null;
try
{
conn = this._Database.DBConns.PopDBConnection();
string cmdText = "Insert into t_guildshare(RoleID,Share,GuildID,RoleName,Rank,FamilyID,FamilyName) VALUES (" + RoleID + "," + Share + "," + GuildID + ",'" + RoleName + "'," + Rank + "," + FamilyID + ",'" + FamilyName + "')";
MySQLCommand cmd = new MySQLCommand(cmdText, conn);
cmd.ExecuteNonQuery();
GameDBManager.SystemServerSQLEvents.AddEvent(string.Format("+SQL: {0}", cmdText), EventLevels.Important);
cmd.Dispose();
cmd = null;
return true;
}
catch (Exception ex)
{
LogManager.WriteLog(LogTypes.Guild, "BUG :" + ex.ToString());

return false;
}
finally
{
if (null != conn)
{
this._Database.DBConns.PushDBConnection(conn);
}
}
}

khi run code thì log báo lỗi về ntn thì sửa ntn ạ cảm ơn nhiều

MySQLDriverCS Exception: MySQLDriverCS Error: wrong query.You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Rank,FamilyID,FamilyName) VALUES (202591,2.58,100035,'A_The_LamSao',10,2,'NoMerc' at line 1 Insert into t_guildshare(RoleID,Share,GuildID,RoleName,Rank,FamilyID,FamilyName) VALUES (202591,2.58,100035,'A_The_LamSao',10,2,'NoMercy')
at MySQLDriverCS.DirectStatement.ExecuteNonQuery()

1 ANSWERS


Answered Thursday, 1:52 a.m.
0

image.png

Share
Viblo
Let's register a Viblo Account to get more interesting posts.