我有选择查询,我关闭了一个方法,所以我可以在任何地方调用它,而不是一次又一次地编写查询这

我有选择查询,我关闭了一个方法,所以我可以在任何地方调用它,而不是一次又一次地编写查询命令

public string mysql_execute_selectfromwhere(string select ,string from, string where, string equalsto)
        {
            ConnMySql.Open();
            MySqlCommand com = ConnMySql.CreateCommand();
            com.CommandText = "SELECT @1 FROM @2 WHERE @3=@4";
            com.Parameters.AddWithValue("@1", select);
            com.Parameters.AddWithValue("@2", from);
            com.Parameters.AddWithValue("@3", where);
            com.Parameters.AddWithValue("@4", equalsto);
            string returnstring = Convert.ToString(com.ExecuteScalar());
            ConnMySql.Close();
            return returnstring;
        }

这就是我调用这个方法的方式

string get = mysql_execute_selectfromwhere("label_name", "label_fields", "lable_id", "17");

我得到以下 mysql 语法错误,我似乎无法正确理解它

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 "label_fields' WHERE 'lable_id'='17" at line 1

如果我的程序有任何其他问题,请同时强调。谢谢

© 版权声明
THE END
喜欢就支持一下吧
点赞118赞赏 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容