System.FormatException

时间:2017-09-06 13:06:17

标签: c# sql

我的sql语句有问题,首先我希望开发一个通用方法,用通用参数更新我的基础 iNT idSELECTED是:

int idSELECTED = Convert.ToInt32(TypeItemsSelection.idTypeItem);

但我不知道如何选择我的id,我的id =通过通用声明id选择

public static int GetId(string Table, string NameiD, int IdSelected)
    {
        Int32 id = IdSelected;
        Int32 genericId=0;
        MySqlConnection connection;
        string connectionString = "server=localhost; user id=root; password=WPF2020; database=imitems";
        connection = new MySqlConnection(connectionString);
        connection.Open();
        MySqlCommand command = new MySqlCommand("SELECT (" + NameiD + ") from  " + Table + "where @name=@select", connection);
        command.Parameters.Add("@name", SqlDbType.Text);
        command.Parameters["@name"].Value = NameiD;
        command.Parameters.AddWithValue("@select", IdSelected);

        MySqlDataReader Reader = command.ExecuteReader();

感谢您的关注

0 个答案:

没有答案