0
protected void Button2_Click(object sender, EventArgs e)
{
    Response.Write(Execute("SELECT NOW()"));
}

public string Execute(string storedProcedureName)
{
    using (EntityConnection connection = (EntityConnection)new EGModel.EGEntity().Connection)
    {
        using (EntityCommand command = connection.CreateCommand())
        {
            command.CommandType = CommandType.Text;
            command.CommandText = storedProcedureName;
            connection.Open();
            return command.ExecuteScalar().ToString();
        }
    }
}

我收到错误“查询语法无效。靠近第 1 行,第 13 列。”;我很好奇,为什么会出现这个错误?(Mysql实体连接)

4

1 回答 1

0
    var A = new EGModel.EGEntity().Connection;

    var command = ((EntityConnection)(A)).StoreConnection.CreateCommand();
    command.CommandType = System.Data.CommandType.Text;
    command.CommandText = "SELECT NOW()";
    ((EntityConnection)(A)).StoreConnection.Open();
    string id = (string)command.ExecuteScalar();

@GTSouza 感谢您的评论,

于 2012-07-13T23:04:38.343 回答